Fix error handling when --extract repository guard fails.
This commit is contained in:
parent
c35f90154f
commit
5ea2d644a2
2 changed files with 18 additions and 2 deletions
|
@ -404,7 +404,11 @@ def collect_configuration_run_summary_logs(config_filenames, args):
|
|||
yield logging.makeLogRecord(dict(levelno=logging.CRITICAL, msg=error))
|
||||
|
||||
if args.extract:
|
||||
try:
|
||||
validate.guard_configuration_contains_repository(args.repository, configs)
|
||||
except ValueError as error:
|
||||
yield logging.makeLogRecord(dict(levelno=logging.CRITICAL, msg=error))
|
||||
return
|
||||
|
||||
for config_filename, config in configs.items():
|
||||
try:
|
||||
|
|
|
@ -57,7 +57,7 @@ def test_collect_configuration_run_summary_logs_info_for_success():
|
|||
assert any(log for log in logs if log.levelno == module.logging.INFO)
|
||||
|
||||
|
||||
def test_collect_configuration_run_summary_still_succeeds_when_extract_true():
|
||||
def test_collect_configuration_run_summary_logs_info_for_success_with_extract():
|
||||
flexmock(module.validate).should_receive('parse_configuration').and_return({'test.yaml': {}})
|
||||
flexmock(module.validate).should_receive('guard_configuration_contains_repository')
|
||||
flexmock(module).should_receive('run_configuration')
|
||||
|
@ -68,6 +68,18 @@ def test_collect_configuration_run_summary_still_succeeds_when_extract_true():
|
|||
assert any(log for log in logs if log.levelno == module.logging.INFO)
|
||||
|
||||
|
||||
def test_collect_configuration_run_summary_logs_critical_for_extract_with_repository_error():
|
||||
flexmock(module.validate).should_receive('parse_configuration').and_return({'test.yaml': {}})
|
||||
flexmock(module.validate).should_receive('guard_configuration_contains_repository').and_raise(
|
||||
ValueError
|
||||
)
|
||||
args = flexmock(extract=True, repository='repo')
|
||||
|
||||
logs = tuple(module.collect_configuration_run_summary_logs(('test.yaml',), args=args))
|
||||
|
||||
assert any(log for log in logs if log.levelno == module.logging.CRITICAL)
|
||||
|
||||
|
||||
def test_collect_configuration_run_summary_logs_critical_for_parse_error():
|
||||
flexmock(module.validate).should_receive('parse_configuration').and_raise(ValueError)
|
||||
args = flexmock(extract=False)
|
||||
|
|
Loading…
Reference in a new issue