diff options
author | Stephen Hines <srhines@google.com> | 2022-01-06 08:57:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-01-06 08:57:50 +0000 |
commit | 9d023268dcf468f9d4bbd874545c9c230e7549b3 (patch) | |
tree | cf4cdad04e1c146844e2a790910cf9cd1b97082a /rust_tools/rust_watch_test.py | |
parent | b36814ef2f8c03cd7d60fd39b1fef69c2910469d (diff) | |
parent | cfc899b23937f6aec9ea2de4967dd8d299f3dc6d (diff) | |
download | toolchain-utils-9d023268dcf468f9d4bbd874545c9c230e7549b3.tar.gz |
Merging 32 commit(s) from Chromium's toolchain-utils am: 7bc245bad9 am: 6323407a0d am: 38574f5e98 am: cfc899b239
Original change: https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/1937961
Change-Id: I1a093ad26060edd9fd26476d0d5d3afff274306a
Diffstat (limited to 'rust_tools/rust_watch_test.py')
-rwxr-xr-x | rust_tools/rust_watch_test.py | 107 |
1 files changed, 37 insertions, 70 deletions
diff --git a/rust_tools/rust_watch_test.py b/rust_tools/rust_watch_test.py index a00f3ddc..30bacbb9 100755 --- a/rust_tools/rust_watch_test.py +++ b/rust_tools/rust_watch_test.py @@ -13,16 +13,15 @@ import time import unittest import unittest.mock -import rust_watch from cros_utils import tiny_render +import rust_watch + class Test(unittest.TestCase): """Tests.""" - def _silence_logs(self): """Silences all log output until the end of the current test.""" - def should_log(_record): return 0 @@ -38,8 +37,8 @@ class Test(unittest.TestCase): def test_release_version_json_round_trips(self): ver = rust_watch.RustReleaseVersion(1, 2, 3) - self.assertEqual( - rust_watch.RustReleaseVersion.from_json(ver.to_json()), ver) + self.assertEqual(rust_watch.RustReleaseVersion.from_json(ver.to_json()), + ver) def test_state_json_round_trips(self): state = rust_watch.State( @@ -96,34 +95,14 @@ class Test(unittest.TestCase): rust_watch.GitCommit('abc123', 'newer commit'), ]) - def test_compose_email_on_a_new_release(self): - new_release = rust_watch.maybe_compose_email( - old_state=rust_watch.State( - last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), - last_gentoo_sha='', - ), - newest_release=rust_watch.RustReleaseVersion(1, 1, 0), - new_gentoo_commits=[], - ) - - self.assertEqual(new_release, ('[rust-watch] new rustc release detected', - ['Rustc tag for v1.1.0 was found.'])) - def test_compose_email_on_a_new_gentoo_commit(self): sha_a = 'a' * 40 - new_commit = rust_watch.maybe_compose_email( - old_state=rust_watch.State( - last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), - last_gentoo_sha='', + new_commit = rust_watch.maybe_compose_email(new_gentoo_commits=[ + rust_watch.GitCommit( + sha=sha_a, + subject='summary_a', ), - newest_release=rust_watch.RustReleaseVersion(1, 0, 0), - new_gentoo_commits=[ - rust_watch.GitCommit( - sha=sha_a, - subject='summary_a', - ), - ], - ) + ], ) self.assertEqual(new_commit, ('[rust-watch] new rust ebuild commit detected', [ @@ -139,60 +118,48 @@ class Test(unittest.TestCase): ]) ])) - def test_compose_email_on_multiple_events(self): - sha_a = 'a' * 40 - new_commit_and_release = rust_watch.maybe_compose_email( + def test_compose_email_composes_nothing_when_no_new_updates_exist(self): + self.assertIsNone(rust_watch.maybe_compose_email(new_gentoo_commits=())) + + def test_compose_bug_creates_bugs_on_new_versions(self): + title, body = rust_watch.maybe_compose_bug( + old_state=rust_watch.State( + last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), + last_gentoo_sha='', + ), + newest_release=rust_watch.RustReleaseVersion(1, 0, 1), + ) + self.assertEqual(title, 'New rustc release detected: v1.0.1') + self.assertTrue(body.startswith('A new release has been detected;')) + + title, body = rust_watch.maybe_compose_bug( old_state=rust_watch.State( last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), last_gentoo_sha='', ), newest_release=rust_watch.RustReleaseVersion(1, 1, 0), - new_gentoo_commits=[ - rust_watch.GitCommit( - sha=sha_a, - subject='summary_a', - ), - ], ) + self.assertEqual(title, 'New rustc release detected: v1.1.0') + self.assertTrue(body.startswith('A new release has been detected;')) - self.assertEqual( - new_commit_and_release, - ('[rust-watch] new rustc release detected; new rust ebuild commit ' - 'detected', [ - 'Rustc tag for v1.1.0 was found.', - tiny_render.line_break, - tiny_render.line_break, - 'commit:', - tiny_render.UnorderedList([ - [ - tiny_render.Link( - rust_watch.gentoo_sha_to_link(sha_a), - sha_a[:12], - ), - ': summary_a', - ], - ]), - ])) + title, body = rust_watch.maybe_compose_bug( + old_state=rust_watch.State( + last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), + last_gentoo_sha='', + ), + newest_release=rust_watch.RustReleaseVersion(2, 0, 0), + ) + self.assertEqual(title, 'New rustc release detected: v2.0.0') + self.assertTrue(body.startswith('A new release has been detected;')) - def test_compose_email_composes_nothing_when_no_new_updates_exist(self): + def test_compose_bug_does_nothing_when_no_new_updates_exist(self): self.assertIsNone( - rust_watch.maybe_compose_email( + rust_watch.maybe_compose_bug( old_state=rust_watch.State( last_seen_release=rust_watch.RustReleaseVersion(1, 0, 0), last_gentoo_sha='', ), newest_release=rust_watch.RustReleaseVersion(1, 0, 0), - new_gentoo_commits=[], - )) - - self.assertIsNone( - rust_watch.maybe_compose_email( - old_state=rust_watch.State( - last_seen_release=rust_watch.RustReleaseVersion(1, 1, 0), - last_gentoo_sha='', - ), - newest_release=rust_watch.RustReleaseVersion(1, 0, 0), - new_gentoo_commits=[], )) |