|
@@ -1,5 +1,8 @@
|
|
|
+import pytest
|
|
|
+
|
|
|
from ...constants import * # NOQA
|
|
|
from . import cmd, generate_archiver_tests, RK_ENCRYPTION
|
|
|
+from ...helpers import Error
|
|
|
|
|
|
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local") # NOQA
|
|
|
|
|
@@ -30,3 +33,31 @@ def test_tag_add_remove(archivers, request):
|
|
|
assert "tags: bb." in output
|
|
|
output = cmd(archiver, "tag", "-a", "archive", "--remove", "bb")
|
|
|
assert "tags: ." in output
|
|
|
+
|
|
|
+
|
|
|
+def test_tag_set_noclobber_special(archivers, request):
|
|
|
+ archiver = request.getfixturevalue(archivers)
|
|
|
+ cmd(archiver, "repo-create", RK_ENCRYPTION)
|
|
|
+ cmd(archiver, "create", "archive", archiver.input_path)
|
|
|
+ output = cmd(archiver, "tag", "-a", "archive", "--set", "@PROT")
|
|
|
+ assert "tags: @PROT." in output
|
|
|
+ # archive now has a special tag.
|
|
|
+ # it must not be possible to accidentally erase such special tags by using --set:
|
|
|
+ output = cmd(archiver, "tag", "-a", "archive", "--set", "clobber")
|
|
|
+ assert "tags: @PROT." in output
|
|
|
+ # it is possible though to use --set if the existing special tags are also given:
|
|
|
+ output = cmd(archiver, "tag", "-a", "archive", "--set", "noclobber", "--set", "@PROT")
|
|
|
+ assert "tags: @PROT,noclobber." in output
|
|
|
+
|
|
|
+
|
|
|
+def test_tag_only_known_special(archivers, request):
|
|
|
+ archiver = request.getfixturevalue(archivers)
|
|
|
+ cmd(archiver, "repo-create", RK_ENCRYPTION)
|
|
|
+ cmd(archiver, "create", "archive", archiver.input_path)
|
|
|
+ # user can't set / add / remove unknown special tags
|
|
|
+ with pytest.raises(Error):
|
|
|
+ cmd(archiver, "tag", "-a", "archive", "--set", "@UNKNOWN")
|
|
|
+ with pytest.raises(Error):
|
|
|
+ cmd(archiver, "tag", "-a", "archive", "--add", "@UNKNOWN")
|
|
|
+ with pytest.raises(Error):
|
|
|
+ cmd(archiver, "tag", "-a", "archive", "--remove", "@UNKNOWN")
|