Browse Source

Allow options to passed to start_container

Ben Firshman 12 years ago
parent
commit
c2e9353760
2 changed files with 9 additions and 2 deletions
  1. 4 2
      plum/service.py
  2. 5 0
      plum/tests/service_test.py

+ 4 - 2
plum/service.py

@@ -29,10 +29,12 @@ class Service(object):
         while len(self.containers) > num:
             self.stop_container()
 
-    def start_container(self):
+    def start_container(self, **override_options):
+        options = dict(self.options)
+        options.update(override_options)
         number = self.next_container_number()
         name = make_name(self.name, number)
-        container = self.client.create_container(name=name, **self.options)
+        container = self.client.create_container(name=name, **options)
         self.client.start(
             container['Id'],
             links=self._get_links(),

+ 5 - 0
plum/tests/service_test.py

@@ -60,6 +60,11 @@ class NameTestCase(DockerClientTestCase):
         self.assertEqual(len(service.containers), 0)
 
     def test_start_container_passes_through_options(self):
+        db = self.create_service('db')
+        db.start_container(environment={'FOO': 'BAR'})
+        self.assertEqual(db.inspect()[0]['Config']['Env'], ['FOO=BAR'])
+
+    def test_start_container_inherits_options_from_constructor(self):
         db = self.create_service('db', environment={'FOO': 'BAR'})
         db.start_container()
         self.assertEqual(db.inspect()[0]['Config']['Env'], ['FOO=BAR'])