Browse code

c8d/integration-cli: Adjust TestBuildClearCmd

Config serialization performed by the graphdriver implementation
maintained the distinction between an empty array and having no Cmd set.

With containerd integration we serialize the OCI types directly that use
the `omitempty` option which doesn't persist that distinction.

Considering that both values should have exactly the same semantics (no
cmd being passed) it should be fine if in this case the Cmd would be
null instead of an empty array.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

Paweł Gronowski authored on 2023/12/07 21:59:00
Showing 1 changed files
... ...
@@ -3144,9 +3144,13 @@ func (s *DockerCLIBuildSuite) TestBuildClearCmd(c *testing.T) {
3144 3144
    ENTRYPOINT ["/bin/bash"]
3145 3145
    CMD []`))
3146 3146
 
3147
-	res := inspectFieldJSON(c, name, "Config.Cmd")
3148
-	if res != "[]" {
3149
-		c.Fatalf("Cmd %s, expected %s", res, "[]")
3147
+	cmd := inspectFieldJSON(c, name, "Config.Cmd")
3148
+	// OCI types specify `omitempty` JSON annotation which doesn't serialize
3149
+	// empty arrays and the Cmd will not be present at all.
3150
+	if testEnv.UsingSnapshotter() {
3151
+		assert.Check(c, is.Equal(cmd, "null"))
3152
+	} else {
3153
+		assert.Check(c, is.Equal(cmd, "[]"))
3150 3154
 	}
3151 3155
 }
3152 3156