Skip to content

Commit

Permalink
Add test for helpers.kapitan_inventory exception
Browse files Browse the repository at this point in the history
  • Loading branch information
simu committed Oct 28, 2024
1 parent c0c2e0b commit ae189df
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import click
import pytest
import responses
import yaml
from responses import matchers
from url_normalize import url_normalize

Expand Down Expand Up @@ -397,3 +398,20 @@ def test_relsymlink_invalid_src_exception(tmp_path: Path):
f"Can't link {src.name} to {tmp_path / 'dst.txt'}. Source does not exist."
in str(e.value)
)


def test_kapitan_inventory(tmp_path: Path, config: Config):
config.inventory.targets_dir.mkdir(parents=True)
config.inventory.classes_dir.mkdir(parents=True)

test = {"parameters": {"foo": "${bar}"}}

with open(config.inventory.targets_dir / "test.yml", "w", encoding="utf-8") as f:
yaml.safe_dump(test, f)

with pytest.raises(click.ClickException) as e:
helpers.kapitan_inventory(config)
assert (
"While rendering inventory: Error while rendering inventory: Error rendering node test: While resolving references: lookup error for reference '${bar}' in parameter 'foo': key 'bar' not found"
in str(e.value)
)

0 comments on commit ae189df

Please sign in to comment.