Skip to content

Commit 4b84271

Browse files
committed
Add unit test to cover file doesn't exist case
1 parent 332b5ac commit 4b84271

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/unit/sdk/test_yaml.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from pathlib import Path
22

3+
import pytest
4+
5+
from infrahub_sdk.exceptions import FileNotValidError
6+
from infrahub_sdk.utils import get_fixtures_dir
37
from infrahub_sdk.yaml import YamlFile
48

59
here = Path(__file__).parent.resolve()
@@ -42,3 +46,9 @@ def test_read_multiple_files_invalid() -> None:
4246
assert yaml_files[0].valid is True
4347
assert yaml_files[1].document_position == 2
4448
assert yaml_files[1].valid is False
49+
50+
51+
def test_load_non_existing_folder():
52+
with pytest.raises(FileNotValidError) as exc:
53+
YamlFile.load_from_disk(paths=[get_fixtures_dir() / "does_not_exist"])
54+
assert "does not exist" in str(exc.value)

0 commit comments

Comments
 (0)