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>
This commit is contained in:
Aravind Vasudevan
2023-08-31 20:57:31 +00:00
committed by LUCI
parent 1e9f7b9e9e
commit e914ec293a
3 changed files with 102 additions and 142 deletions

View File

@ -23,7 +23,6 @@ class TestRepoLogger(unittest.TestCase):
def test_error_logs_error(self):
"""Test if error fn outputs logs."""
logger = RepoLogger(__name__)
RepoLogger.errors[:] = []
result = None
def mock_handler(log):
@ -42,7 +41,6 @@ class TestRepoLogger(unittest.TestCase):
def test_warning_logs_error(self):
"""Test if warning fn outputs logs."""
logger = RepoLogger(__name__)
RepoLogger.errors[:] = []
result = None
def mock_handler(log):
@ -58,30 +56,9 @@ class TestRepoLogger(unittest.TestCase):
self.assertEqual(result, "You know the rules and so do I (do I)")
def test_error_aggregates_error_msg(self):
"""Test if error fn aggregates error logs."""
logger = RepoLogger(__name__)
RepoLogger.errors[:] = []
logger.error("A full commitment's what I'm thinking of")
logger.error("You wouldn't get this from any other guy")
logger.error("I just wanna tell you how I'm feeling")
logger.error("Gotta make you understand")
self.assertEqual(
RepoLogger.errors[:],
[
"A full commitment's what I'm thinking of",
"You wouldn't get this from any other guy",
"I just wanna tell you how I'm feeling",
"Gotta make you understand",
],
)
def test_log_aggregated_errors_logs_aggregated_errors(self):
"""Test if log_aggregated_errors outputs aggregated errors."""
logger = RepoLogger(__name__)
RepoLogger.errors[:] = []
result = []
def mock_handler(log):
@ -96,7 +73,13 @@ class TestRepoLogger(unittest.TestCase):
logger.error("Never gonna give you up")
logger.error("Never gonna let you down")
logger.error("Never gonna run around and desert you")
logger.log_aggregated_errors()
logger.log_aggregated_errors(
[
"Never gonna give you up",
"Never gonna let you down",
"Never gonna run around and desert you",
]
)
self.assertEqual(
result,