tests/test_commands.py | 17 ++++++++++++-----
tests/test_commands/test-invalid-tag.yml | 9 +++++++++
tests/test_commands/test-shallow.yml | 5 +++++
3 files changed, 26 insertions(+), 5 deletions(-)
create mode 100644 tests/test_commands/test-invalid-tag.yml
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 13386c7..777227a 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -31,7 +31,7 @@ import pytest
from kas import kas
from kas.libkas import TaskExecError, KasUserError, run_cmd
from kas.attestation import file_digest_slow
-from kas.repos import RepoFetchError
+from kas.repos import RepoFetchError, RepoRefError
@pytest.mark.dirsfromenv
@@ -99,12 +99,19 @@ def test_checkout(monkeykas, tmpdir):
kas.kas(['checkout', '--update', 'test-no-commit.yml'])
-def test_invalid_checkout(monkeykas, tmpdir, capsys):
+...@pytest.mark.parametrize(
+ "file, error",
+ [
+ ('test-invalid.yml', TaskExecError),
+ ('test-invalid-tag.yml', RepoRefError),
+ ],
+)
+def test_invalid_checkout(monkeykas, tmpdir, capsys, file, error):
tdir = str(tmpdir / 'test_commands')
shutil.copytree('tests/test_commands', tdir)
monkeykas.chdir(tdir)
- with pytest.raises(TaskExecError):
- kas.kas(['checkout', 'test-invalid.yml'])
+ with pytest.raises(error):
+ kas.kas(['checkout', file])
@pytest.mark.dirsfromenv
@@ -151,7 +158,7 @@ def test_checkout_shallow(monkeykas, tmpdir):
with monkeykas.context() as mp:
mp.setenv('KAS_CLONE_DEPTH', '1')
kas.kas(['checkout', 'test-shallow.yml'])
- for repo in ['kas_1', 'kas_2', 'kas_3', 'kas_4']:
+ for repo in ['kas_1', 'kas_2', 'kas_3', 'kas_4', 'kas_5']:
repo_path = monkeykas.get_kwd() / repo
output = subprocess.check_output(
['git', 'rev-list', '--count', 'HEAD'], cwd=repo_path)
diff --git a/tests/test_commands/test-invalid-tag.yml b/tests/test_commands/test-invalid-tag.yml
new file mode 100644
index 0000000..ab575d6
--- /dev/null
+++ b/tests/test_commands/test-invalid-tag.yml
@@ -0,0 +1,9 @@
+header:
+ version: 15
+
+repos:
+ kas_invalid:
+ url:
https://github.com/siemens/kas.git
+ tag: '4.3'
+ # non matching commit (tag: 4.2)
+ commit: 23211cbd3518936d83169722d1eb40656344ba27
diff --git a/tests/test_commands/test-shallow.yml b/tests/test_commands/test-shallow.yml
index dfd711c..c5a7a15 100644
--- a/tests/test_commands/test-shallow.yml
+++ b/tests/test_commands/test-shallow.yml
@@ -21,3 +21,8 @@ repos:
url:
https://github.com/siemens/kas.git
# keep legacy refspec here for testing purposes
refspec: master
+
+ kas_5:
+ url:
https://github.com/siemens/kas.git
+ tag: '4.3'
+ commit: beb5b60c6823ec53300efb3b854a5a921b22bd3d
--
2.39.5