]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests.util ensure dmcrypt_close will skip non-existent paths
authorAlfredo Deza <adeza@redhat.com>
Mon, 13 Aug 2018 19:42:26 +0000 (15:42 -0400)
committerAlfredo Deza <adeza@redhat.com>
Tue, 14 Aug 2018 14:47:14 +0000 (10:47 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_encryption.py

index 3d84e55394163dcc66b42ce4147295536d4b5047..8cca42689b41ec0652a5b818661c5b2b01ca6371 100644 (file)
@@ -17,3 +17,19 @@ class TestStatus(object):
         out = ['some line here', '  ']
         stub_call((out, '', 0))
         assert encryption.status('/dev/sdc1') == {}
+
+
+class TestDmcryptClose(object):
+
+    def test_mapper_exists(self, fake_run, tmpfile):
+        file_name = tmpfile(name='mapper-device')
+        encryption.dmcrypt_close(file_name)
+        arguments = fake_run.calls[0]['args'][0]
+        assert arguments[0] == 'cryptsetup'
+        assert arguments[1] == 'remove'
+        assert arguments[2].startswith('/')
+
+    def test_mapper_does_not_exist(self, fake_run):
+        file_name = '/path/does/not/exist'
+        encryption.dmcrypt_close(file_name)
+        assert fake_run.calls == []