diff --git a/tests/test_options.py b/tests/test_options.py index e54a0e2b..a855279a 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -104,3 +104,35 @@ def test_incorrect_output_type_cfg_file(mock_parse, mock_run, mock_service): finally: os.remove(config_path) + + +@patch('ipahealthcheck.core.core.run_service_plugins') +@patch('ipahealthcheck.core.core.run_plugins') +@patch('ipahealthcheck.core.core.parse_options') +def test_incorrect_delimiter_cfg_file(mock_parse, mock_run, mock_service): + """ + Test the error message is user-friendly if the incorrect delimiter is + used in cfg file + + Related: https://bugzilla.redhat.com/show_bug.cgi?id=2079739 + """ + mock_service.return_value = (Results(), []) + mock_run.return_value = Results() + mock_parse.return_value = options + fd, config_path = tempfile.mkstemp() + os.close(fd) + with open(config_path, "w") as fd: + fd.write('[default]\n') + fd.write('output_type;human\n') + + try: + run = RunChecks([], config_path) + + f = io.StringIO() + with redirect_stdout(f): + run.run_healthcheck() + + assert "contains parsing errors" in f.getvalue() + + finally: + os.remove(config_path)