|
@@ -32,20 +32,17 @@ func (s *DockerSuite) TestInspectApiContainerResponse(c *check.C) {
|
|
|
body := getInspectBody(c, cs.version, cleanedContainerID)
|
|
|
|
|
|
var inspectJSON map[string]interface{}
|
|
|
- if err := json.Unmarshal(body, &inspectJSON); err != nil {
|
|
|
- c.Fatalf("unable to unmarshal body for version %s: %v", cs.version, err)
|
|
|
- }
|
|
|
+ err := json.Unmarshal(body, &inspectJSON)
|
|
|
+ c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version %s", cs.version))
|
|
|
|
|
|
for _, key := range cs.keys {
|
|
|
- if _, ok := inspectJSON[key]; !ok {
|
|
|
- c.Fatalf("%s does not exist in response for version %s", key, cs.version)
|
|
|
- }
|
|
|
+ _, ok := inspectJSON[key]
|
|
|
+ c.Check(ok, checker.True, check.Commentf("%s does not exist in response for version %s", key, cs.version))
|
|
|
}
|
|
|
|
|
|
//Issue #6830: type not properly converted to JSON/back
|
|
|
- if _, ok := inspectJSON["Path"].(bool); ok {
|
|
|
- c.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
|
|
- }
|
|
|
+ _, ok := inspectJSON["Path"].(bool)
|
|
|
+ c.Assert(ok, checker.False, check.Commentf("Path of `true` should not be converted to boolean `true` via JSON marshalling"))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -59,18 +56,14 @@ func (s *DockerSuite) TestInspectApiContainerVolumeDriverLegacy(c *check.C) {
|
|
|
body := getInspectBody(c, version, cleanedContainerID)
|
|
|
|
|
|
var inspectJSON map[string]interface{}
|
|
|
- if err := json.Unmarshal(body, &inspectJSON); err != nil {
|
|
|
- c.Fatalf("unable to unmarshal body for version %s: %v", version, err)
|
|
|
- }
|
|
|
+ err := json.Unmarshal(body, &inspectJSON)
|
|
|
+ c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version %s", version))
|
|
|
|
|
|
config, ok := inspectJSON["Config"]
|
|
|
- if !ok {
|
|
|
- c.Fatal("Unable to find 'Config'")
|
|
|
- }
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
|
|
|
cfg := config.(map[string]interface{})
|
|
|
- if _, ok := cfg["VolumeDriver"]; !ok {
|
|
|
- c.Fatalf("Api version %s expected to include VolumeDriver in 'Config'", version)
|
|
|
- }
|
|
|
+ _, ok = cfg["VolumeDriver"]
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Api version %s expected to include VolumeDriver in 'Config'", version))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -82,27 +75,20 @@ func (s *DockerSuite) TestInspectApiContainerVolumeDriver(c *check.C) {
|
|
|
body := getInspectBody(c, "v1.21", cleanedContainerID)
|
|
|
|
|
|
var inspectJSON map[string]interface{}
|
|
|
- if err := json.Unmarshal(body, &inspectJSON); err != nil {
|
|
|
- c.Fatalf("unable to unmarshal body for version 1.21: %v", err)
|
|
|
- }
|
|
|
+ err := json.Unmarshal(body, &inspectJSON)
|
|
|
+ c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version 1.21"))
|
|
|
|
|
|
config, ok := inspectJSON["Config"]
|
|
|
- if !ok {
|
|
|
- c.Fatal("Unable to find 'Config'")
|
|
|
- }
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
|
|
|
cfg := config.(map[string]interface{})
|
|
|
- if _, ok := cfg["VolumeDriver"]; ok {
|
|
|
- c.Fatal("Api version 1.21 expected to not include VolumeDriver in 'Config'")
|
|
|
- }
|
|
|
+ _, ok = cfg["VolumeDriver"]
|
|
|
+ c.Assert(ok, checker.False, check.Commentf("Api version 1.21 expected to not include VolumeDriver in 'Config'"))
|
|
|
|
|
|
config, ok = inspectJSON["HostConfig"]
|
|
|
- if !ok {
|
|
|
- c.Fatal("Unable to find 'HostConfig'")
|
|
|
- }
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
|
|
|
cfg = config.(map[string]interface{})
|
|
|
- if _, ok := cfg["VolumeDriver"]; !ok {
|
|
|
- c.Fatal("Api version 1.21 expected to include VolumeDriver in 'HostConfig'")
|
|
|
- }
|
|
|
+ _, ok = cfg["VolumeDriver"]
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Api version 1.21 expected to include VolumeDriver in 'HostConfig'"))
|
|
|
}
|
|
|
|
|
|
func (s *DockerSuite) TestInspectApiImageResponse(c *check.C) {
|
|
@@ -111,18 +97,16 @@ func (s *DockerSuite) TestInspectApiImageResponse(c *check.C) {
|
|
|
endpoint := "/images/busybox/json"
|
|
|
status, body, err := sockRequest("GET", endpoint, nil)
|
|
|
|
|
|
- c.Assert(err, check.IsNil)
|
|
|
- c.Assert(status, check.Equals, http.StatusOK)
|
|
|
+ c.Assert(err, checker.IsNil)
|
|
|
+ c.Assert(status, checker.Equals, http.StatusOK)
|
|
|
|
|
|
var imageJSON types.ImageInspect
|
|
|
- if err = json.Unmarshal(body, &imageJSON); err != nil {
|
|
|
- c.Fatalf("unable to unmarshal body for latest version: %v", err)
|
|
|
- }
|
|
|
+ err = json.Unmarshal(body, &imageJSON)
|
|
|
+ c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for latest version"))
|
|
|
+ c.Assert(imageJSON.RepoTags, checker.HasLen, 2)
|
|
|
|
|
|
- c.Assert(len(imageJSON.RepoTags), check.Equals, 2)
|
|
|
-
|
|
|
- c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:latest"), check.Equals, true)
|
|
|
- c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:mytag"), check.Equals, true)
|
|
|
+ c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:latest"), checker.Equals, true)
|
|
|
+ c.Assert(stringutils.InSlice(imageJSON.RepoTags, "busybox:mytag"), checker.Equals, true)
|
|
|
}
|
|
|
|
|
|
// #17131, #17139, #17173
|
|
@@ -136,19 +120,14 @@ func (s *DockerSuite) TestInspectApiEmptyFieldsInConfigPre121(c *check.C) {
|
|
|
body := getInspectBody(c, version, cleanedContainerID)
|
|
|
|
|
|
var inspectJSON map[string]interface{}
|
|
|
- if err := json.Unmarshal(body, &inspectJSON); err != nil {
|
|
|
- c.Fatalf("unable to unmarshal body for version %s: %v", version, err)
|
|
|
- }
|
|
|
-
|
|
|
+ err := json.Unmarshal(body, &inspectJSON)
|
|
|
+ c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version %s", version))
|
|
|
config, ok := inspectJSON["Config"]
|
|
|
- if !ok {
|
|
|
- c.Fatal("Unable to find 'Config'")
|
|
|
- }
|
|
|
+ c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
|
|
|
cfg := config.(map[string]interface{})
|
|
|
for _, f := range []string{"MacAddress", "NetworkDisabled", "ExposedPorts"} {
|
|
|
- if _, ok := cfg[f]; !ok {
|
|
|
- c.Fatalf("Api version %s expected to include %s in 'Config'", version, f)
|
|
|
- }
|
|
|
+ _, ok := cfg[f]
|
|
|
+ c.Check(ok, checker.True, check.Commentf("Api version %s expected to include %s in 'Config'", version, f))
|
|
|
}
|
|
|
}
|
|
|
}
|