From d1ca0267adbd17575037b5bf433bf0883a4b64a7 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Mon, 22 Apr 2024 20:31:47 +0200 Subject: [PATCH] tests: add simple initial test for the -k arg As the argument is common to multiple commands, start by adding a test for for-all-repos. The test currently only checks that the repository is not cloned when it isn't already present. Future tests could confirm other changes to the configuration are not made. Signed-off-by: Christopher Larson Signed-off-by: Jan Kiszka --- tests/test_commands.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_commands.py b/tests/test_commands.py index 0193c1af..2f7fdcb0 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -47,6 +47,19 @@ def test_for_all_repos(monkeykas, tmpdir): == 'e9ca55a239caa1a2098e1d48773a29ea53c6cab2' +def test_for_all_repos_keep_config_unchanged(monkeykas, tmpdir): + tdir = str(tmpdir / 'test_commands') + shutil.copytree('tests/test_commands', tdir) + monkeykas.chdir(tdir) + + with pytest.raises(FileNotFoundError, match=r'.*/kas_1.[01]'): + kas.kas(['for-all-repos', '--keep-config-unchanged', 'test.yml', + 'pwd']) + + assert not os.path.exists('kas_1.0') + assert not os.path.exists("kas_1.1") + + def test_checkout(monkeykas, tmpdir): tdir = str(tmpdir / 'test_commands') shutil.copytree('tests/test_commands', tdir)