Browse Source

Don't warn when the container volume is specified as a compose option.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 10 years ago
parent
commit
ad9011ed96
2 changed files with 13 additions and 0 deletions
  1. 1 0
      compose/service.py
  2. 12 0
      tests/unit/service_test.py

+ 1 - 0
compose/service.py

@@ -880,6 +880,7 @@ def warn_on_masked_volume(volumes_option, container_volumes, service):
 
     for volume in volumes_option:
         if (
+            volume.external and
             volume.internal in container_volumes and
             container_volumes.get(volume.internal) != volume.external
         ):

+ 12 - 0
tests/unit/service_test.py

@@ -742,6 +742,18 @@ class ServiceVolumesTest(unittest.TestCase):
 
         assert not mock_log.warn.called
 
+    def test_warn_on_masked_no_warning_with_container_only_option(self):
+        volumes_option = [VolumeSpec(None, '/path', 'rw')]
+        container_volumes = [
+            VolumeSpec('/var/lib/docker/volume/path', '/path', 'rw')
+        ]
+        service = 'service_name'
+
+        with mock.patch('compose.service.log', autospec=True) as mock_log:
+            warn_on_masked_volume(volumes_option, container_volumes, service)
+
+        assert not mock_log.warn.called
+
     def test_create_with_special_volume_mode(self):
         self.mock_client.inspect_image.return_value = {'Id': 'imageid'}