From e9d4f3edcecf541ae31fbf2bc174b56a12895df0 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Wed, 17 Apr 2019 03:18:12 +0200
Subject: [PATCH] Test detection of running bacup process container

---
 tests/tests.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tests/tests.py b/tests/tests.py
index e9e7b9e..24be44a 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -144,3 +144,21 @@ class ResticBackupTests(unittest.TestCase):
         mounts = web_service.filter_mounts()
         self.assertEqual(len(mounts), 1)
         self.assertEqual(mounts[0].source, '/srv/files/media')
+
+    def test_find_running_backup_container(self):
+        containers = self.createContainers()
+        with mock.patch(list_containers_func, fixtures.containers(containers=containers)):
+            cnt = RunningContainers()
+            self.assertFalse(cnt.backup_process_running)
+
+        containers += [
+            {
+                'service': 'backup_runner',
+                'labels': {
+                    'restic-volume-backup.runner': 'True',
+                },
+            },
+        ]
+        with mock.patch(list_containers_func, fixtures.containers(containers=containers)):
+            cnt = RunningContainers()
+            self.assertTrue(cnt.backup_process_running)