Browse Source

Add unit test for image digests in config

Add two unit tests to validate that the denormalize_service_dict
function still works without passing a third argument for image_digest,
and correctly uses an image digest if one is provided.

Signed-off-by: King Chung Huang <[email protected]>
King Chung Huang 9 years ago
parent
commit
0464476f08
1 changed files with 19 additions and 0 deletions
  1. 19 0
      tests/unit/config/config_test.py

+ 19 - 0
tests/unit/config/config_test.py

@@ -3654,6 +3654,25 @@ class SerializeTest(unittest.TestCase):
         assert denormalized_service['healthcheck']['interval'] == '100s'
         assert denormalized_service['healthcheck']['timeout'] == '30s'
 
+    def test_denormalize_image_has_digest(self):
+        service_dict = {
+            'image': 'busybox'
+        }
+        image_digest = 'busybox@sha256:abcde'
+
+        assert denormalize_service_dict(service_dict, V3_0, image_digest) == {
+            'image': 'busybox@sha256:abcde'
+        }
+
+    def test_denormalize_image_no_digest(self):
+        service_dict = {
+            'image': 'busybox'
+        }
+
+        assert denormalize_service_dict(service_dict, V3_0) == {
+            'image': 'busybox'
+        }
+
     def test_serialize_secrets(self):
         service_dict = {
             'image': 'example/web',