| @@ -3,14 +3,16 @@ from focker.image import validate_spec, \ | |||||
| build_squeeze, \ | build_squeeze, \ | ||||
| build, \ | build, \ | ||||
| command_image_build, \ | command_image_build, \ | ||||
| command_image_tag | |||||
| command_image_tag, \ | |||||
| command_image_untag | |||||
| import subprocess | import subprocess | ||||
| from tempfile import TemporaryDirectory | from tempfile import TemporaryDirectory | ||||
| import focker.image | import focker.image | ||||
| import os | import os | ||||
| from focker.zfs import zfs_find, \ | from focker.zfs import zfs_find, \ | ||||
| zfs_mountpoint, \ | zfs_mountpoint, \ | ||||
| zfs_exists_snapshot_sha256 | |||||
| zfs_exists_snapshot_sha256, \ | |||||
| zfs_parse_output | |||||
| from focker.misc import focker_unlock | from focker.misc import focker_unlock | ||||
| import yaml | import yaml | ||||
| @@ -142,3 +144,21 @@ def test_command_image_tag(): | |||||
| zfs_find(t, focker_type='image') | zfs_find(t, focker_type='image') | ||||
| with pytest.raises(ValueError): | with pytest.raises(ValueError): | ||||
| zfs_find('test-command-image-tag', focker_type='image') | zfs_find('test-command-image-tag', focker_type='image') | ||||
| def test_command_image_untag(): | |||||
| focker_unlock() | |||||
| subprocess.check_output(['focker', 'image', 'remove', '--force', '-R', 'test-command-image-untag']) | |||||
| subprocess.check_output(['focker', 'bootstrap', '--dry-run', '-t', 'test-command-image-untag', 'test-command-image-untag-1', 'test-command-image-untag-2']) | |||||
| name, sha256 = zfs_find('test-command-image-untag', focker_type='image') | |||||
| args = lambda: 0 | |||||
| args.tags = ['test-command-image-untag-1', 'test-command-image-untag-2'] | |||||
| command_image_untag(args) | |||||
| tags = zfs_parse_output(['zfs', 'get', '-H', 'focker:tags', name]) | |||||
| tags = tags[0][2].split(',') | |||||
| assert tags == ['test-command-image-untag'] | |||||
| with pytest.raises(ValueError): | |||||
| zfs_find('test-command-image-untag-1', focker_type='image') | |||||
| with pytest.raises(ValueError): | |||||
| zfs_find('test-command-image-untag-2', focker_type='image') | |||||
| subprocess.check_output(['focker', 'image', 'remove', 'test-command-image-untag']) | |||||