Skip to content

Commit

Permalink
Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Dec 9, 2024
1 parent c67e50a commit 88a9e5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/cfnlint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def __init__(self, config: ConfigMixIn) -> None:
self.config.templates
except ValueError as e:
self._cli_output([Match(str(e), ConfigError(), None)])
sys.exit(1)
# load registry schemas before patching
if self.config.registry_schemas:
for path in self.config.registry_schemas:
Expand Down
16 changes: 16 additions & 0 deletions test/unit/module/runner/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SPDX-License-Identifier: MIT-0
"""

from io import StringIO
from unittest.mock import patch

import pytest
Expand Down Expand Up @@ -93,3 +94,18 @@ def test_init_schemas(name, registry_path, patch_path, expected):

PROVIDER_SCHEMA_MANAGER._registry_schemas = {}
PROVIDER_SCHEMA_MANAGER.reset()


def test_no_templates():
params = ["--template", "does-not-exist.yaml"]

config = ConfigMixIn(params)
with patch("sys.exit") as exit:
with patch("sys.stdout", new=StringIO()) as out:
exit.assert_not_called()
Runner(config)
assert out.getvalue().strip() == (
"E0003 does-not-exist.yaml could not "
"be processed by glob.glob\nNone:1:1"
)
exit.assert_called_once_with(2)

0 comments on commit 88a9e5f

Please sign in to comment.