From e2a2cf2d26e8fc7f920dc4ba79a13462f3b8279f Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Tue, 26 Nov 2019 14:24:42 +0100 Subject: [PATCH] tests: volumes_for_backup --- tests/tests.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/tests.py b/tests/tests.py index b32f13b..f16a871 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -82,6 +82,37 @@ class ResticBackupTests(unittest.TestCase): self.assertNotEqual(web_service, None) self.assertEqual(len(web_service.filter_mounts()), 1) + def test_volumes_for_backup(self): + containers = self.createContainers() + containers += [ + { + 'service': 'web', + 'labels': { + 'restic-volume-backup.volumes': True, + }, + 'mounts': [{ + 'Source': 'test', + 'Destination': 'test', + 'Type': 'bind', + }] + }, + { + 'service': 'mysql', + 'labels': { + 'restic-volume-backup.mysql': True, + }, + 'mounts': [{ + 'Source': 'data', + 'Destination': 'data', + 'Type': 'bind', + }] + }, + ] + with mock.patch(list_containers_func, fixtures.containers(containers=containers)): + cnt = RunningContainers() + self.assertTrue(len(cnt.containers_for_backup()) == 2) + self.assertEqual(cnt.generate_backup_mounts(), {'test': {'bind': '/backup/web/test', 'mode': 'ro'}}) + def test_include(self): containers = self.createContainers() containers += [