summaryrefslogtreecommitdiffstats
path: root/tests/test_repo_logging.py
diff options
context:
space:
mode:
authorAravind Vasudevan <aravindvasudev@google.com>2023-08-31 20:57:31 +0000
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-08-31 22:29:51 +0000
commite914ec293a414dc6cf092c1323c1c059943e706f (patch)
tree165d9228c6d98bfa8e1c23e22bbdc1d297ae111c /tests/test_repo_logging.py
parent1e9f7b9e9ef473305d10a26a48138bc6ad38ccf6 (diff)
downloadgit-repo-e914ec293a414dc6cf092c1323c1c059943e706f.tar.gz
sync: Use repo logger within sync
Bug: b/292704435 Change-Id: Iceb3ad5111e656a1ff9730ae5deb032a9b43b4a5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383454 Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_repo_logging.py')
-rw-r--r--tests/test_repo_logging.py31
1 files changed, 7 insertions, 24 deletions
diff --git a/tests/test_repo_logging.py b/tests/test_repo_logging.py
index 5402a90b..b51e6270 100644
--- a/tests/test_repo_logging.py
+++ b/tests/test_repo_logging.py
@@ -23,7 +23,6 @@ class TestRepoLogger(unittest.TestCase):
23 def test_error_logs_error(self): 23 def test_error_logs_error(self):
24 """Test if error fn outputs logs.""" 24 """Test if error fn outputs logs."""
25 logger = RepoLogger(__name__) 25 logger = RepoLogger(__name__)
26 RepoLogger.errors[:] = []
27 result = None 26 result = None
28 27
29 def mock_handler(log): 28 def mock_handler(log):
@@ -42,7 +41,6 @@ class TestRepoLogger(unittest.TestCase):
42 def test_warning_logs_error(self): 41 def test_warning_logs_error(self):
43 """Test if warning fn outputs logs.""" 42 """Test if warning fn outputs logs."""
44 logger = RepoLogger(__name__) 43 logger = RepoLogger(__name__)
45 RepoLogger.errors[:] = []
46 result = None 44 result = None
47 45
48 def mock_handler(log): 46 def mock_handler(log):
@@ -58,30 +56,9 @@ class TestRepoLogger(unittest.TestCase):
58 56
59 self.assertEqual(result, "You know the rules and so do I (do I)") 57 self.assertEqual(result, "You know the rules and so do I (do I)")
60 58
61 def test_error_aggregates_error_msg(self):
62 """Test if error fn aggregates error logs."""
63 logger = RepoLogger(__name__)
64 RepoLogger.errors[:] = []
65
66 logger.error("A full commitment's what I'm thinking of")
67 logger.error("You wouldn't get this from any other guy")
68 logger.error("I just wanna tell you how I'm feeling")
69 logger.error("Gotta make you understand")
70
71 self.assertEqual(
72 RepoLogger.errors[:],
73 [
74 "A full commitment's what I'm thinking of",
75 "You wouldn't get this from any other guy",
76 "I just wanna tell you how I'm feeling",
77 "Gotta make you understand",
78 ],
79 )
80
81 def test_log_aggregated_errors_logs_aggregated_errors(self): 59 def test_log_aggregated_errors_logs_aggregated_errors(self):
82 """Test if log_aggregated_errors outputs aggregated errors.""" 60 """Test if log_aggregated_errors outputs aggregated errors."""
83 logger = RepoLogger(__name__) 61 logger = RepoLogger(__name__)
84 RepoLogger.errors[:] = []
85 result = [] 62 result = []
86 63
87 def mock_handler(log): 64 def mock_handler(log):
@@ -96,7 +73,13 @@ class TestRepoLogger(unittest.TestCase):
96 logger.error("Never gonna give you up") 73 logger.error("Never gonna give you up")
97 logger.error("Never gonna let you down") 74 logger.error("Never gonna let you down")
98 logger.error("Never gonna run around and desert you") 75 logger.error("Never gonna run around and desert you")
99 logger.log_aggregated_errors() 76 logger.log_aggregated_errors(
77 [
78 "Never gonna give you up",
79 "Never gonna let you down",
80 "Never gonna run around and desert you",
81 ]
82 )
100 83
101 self.assertEqual( 84 self.assertEqual(
102 result, 85 result,