From 5095d85d597e24345bb00ed7799f5ae4f49bccf6 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Sat, 30 May 2020 07:40:15 +0200 Subject: [PATCH] Add test_command_image_untag(). --- tests/test_image.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/test_image.py b/tests/test_image.py index 194cd4b..6efa047 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -3,14 +3,16 @@ from focker.image import validate_spec, \ build_squeeze, \ build, \ command_image_build, \ - command_image_tag + command_image_tag, \ + command_image_untag import subprocess from tempfile import TemporaryDirectory import focker.image import os from focker.zfs import zfs_find, \ zfs_mountpoint, \ - zfs_exists_snapshot_sha256 + zfs_exists_snapshot_sha256, \ + zfs_parse_output from focker.misc import focker_unlock import yaml @@ -142,3 +144,21 @@ def test_command_image_tag(): zfs_find(t, focker_type='image') with pytest.raises(ValueError): 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'])