From d809496eb25b060a8d5b26dba18277c8918198a2 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 17 Apr 2019 02:45:01 +0200 Subject: [PATCH] Test exclude patterns --- tests/tests.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/tests/tests.py b/tests/tests.py index cee92b3..e9e7b9e 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -109,9 +109,38 @@ class ResticBackupTests(unittest.TestCase): web_service = cnt.get_service('web') self.assertNotEqual(web_service, None, msg="Web service not found") - mounts = list(web_service.filter_mounts()) + mounts = web_service.filter_mounts() self.assertEqual(len(mounts), 1) self.assertEqual(mounts[0].source, '/srv/files/media') def test_exclude(self): - pass + containers = self.createContainers() + containers += [ + { + 'service': 'web', + 'labels': { + 'restic-volume-backup.exclude': 'stuff', + }, + 'mounts': [ + { + 'Source': '/srv/files/media', + 'Destination': '/srv/media', + 'Type': 'bind', + }, + { + 'Source': '/srv/files/stuff', + 'Destination': '/srv/stuff', + 'Type': 'bind', + }, + ] + }, + ] + with mock.patch(list_containers_func, fixtures.containers(containers=containers)): + cnt = RunningContainers() + + web_service = cnt.get_service('web') + self.assertNotEqual(web_service, None, msg="Web service not found") + + mounts = web_service.filter_mounts() + self.assertEqual(len(mounts), 1) + self.assertEqual(mounts[0].source, '/srv/files/media')