summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord11wtq <chris@w3style.co.uk>2014-06-08 13:16:14 +0000
committerChris Corbyn <chris@w3style.co.uk>2014-06-09 01:31:49 +0000
commit6c4299039a1e6c13dea0b9c3eaa08a1bab345ceb (patch)
tree0ec012fc9894b8a4c083d1c0f5296e2135faa007
parent655d347ea2b298fd9928718d9c0dfc66fe189205 (diff)
Write integration tests for `--keep-old` in the CLI
Signed-off-by: Chris Corbyn <chris@w3style.co.uk>
-rw-r--r--tests/integration/cli_test.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/integration/cli_test.py b/tests/integration/cli_test.py
index dbdd2a8a..c615b167 100644
--- a/tests/integration/cli_test.py
+++ b/tests/integration/cli_test.py
@@ -74,6 +74,35 @@ class CLITestCase(DockerClientTestCase):
self.assertEqual(len(db.containers()), 0)
self.assertEqual(len(console.containers()), 0)
+ def test_up_with_recreate(self):
+ self.command.dispatch(['up', '-d'], None)
+ service = self.command.project.get_service('simple')
+ self.assertEqual(len(service.containers()), 1)
+
+ old_ids = [c.id for c in service.containers()]
+
+ self.command.dispatch(['up', '-d'], None)
+ self.assertEqual(len(service.containers()), 1)
+
+ new_ids = [c.id for c in service.containers()]
+
+ self.assertNotEqual(old_ids, new_ids)
+
+ def test_up_with_keep_old(self):
+ self.command.dispatch(['up', '-d'], None)
+ service = self.command.project.get_service('simple')
+ self.assertEqual(len(service.containers()), 1)
+
+ old_ids = [c.id for c in service.containers()]
+
+ self.command.dispatch([str('up'), str('-d'), str('--keep-old')], None)
+ self.assertEqual(len(service.containers()), 1)
+
+ new_ids = [c.id for c in service.containers()]
+
+ self.assertEqual(old_ids, new_ids)
+
+
@patch('sys.stdout', new_callable=StringIO)
def test_run_with_links(self, mock_stdout):
mock_stdout.fileno = lambda: 1
@@ -94,6 +123,24 @@ class CLITestCase(DockerClientTestCase):
db = self.command.project.get_service('db')
self.assertEqual(len(db.containers()), 0)
+ @patch('sys.stdout', new_callable=StringIO)
+ def test_run_does_not_recreate_linked_containers(self, mock_stdout):
+ mock_stdout.fileno = lambda: 1
+
+ self.command.base_dir = 'tests/fixtures/links-figfile'
+ self.command.dispatch([str('up'), str('-d'), str('db')], None)
+ db = self.command.project.get_service('db')
+ self.assertEqual(len(db.containers()), 1)
+
+ old_ids = [c.id for c in db.containers()]
+
+ self.command.dispatch([str('run'), str('web'), str('/bin/true')], None)
+ self.assertEqual(len(db.containers()), 1)
+
+ new_ids = [c.id for c in db.containers()]
+
+ self.assertEqual(old_ids, new_ids)
+
def test_rm(self):
service = self.command.project.get_service('simple')
service.create_container()