Browse code

Adding test for "GET /images/(name)/history" API.

Closes #12284.

Signed-off-by: Raghuram Devarakonda <draghuram@gmail.com>

Raghuram Devarakonda authored on 2015/05/02 14:30:35
Showing 1 changed files
... ...
@@ -121,3 +121,25 @@ func (s *DockerSuite) TestApiImagesDelete(c *check.C) {
121 121
 	c.Assert(status, check.Equals, http.StatusOK)
122 122
 	c.Assert(err, check.IsNil)
123 123
 }
124
+
125
+func (s *DockerSuite) TestApiImagesHistory(c *check.C) {
126
+	testRequires(c, Network)
127
+	name := "test-api-images-history"
128
+	out, err := buildImage(name, "FROM hello-world\nENV FOO bar", false)
129
+	c.Assert(err, check.IsNil)
130
+
131
+	defer deleteImages(name)
132
+	id := strings.TrimSpace(out)
133
+
134
+	status, body, err := sockRequest("GET", "/images/"+id+"/history", nil)
135
+	c.Assert(err, check.IsNil)
136
+	c.Assert(status, check.Equals, http.StatusOK)
137
+
138
+	var historydata []types.ImageHistory
139
+	if err = json.Unmarshal(body, &historydata); err != nil {
140
+		c.Fatalf("Error on unmarshal: %s", err)
141
+	}
142
+
143
+	c.Assert(len(historydata), check.Not(check.Equals), 0)
144
+	c.Assert(historydata[0].Tags[0], check.Equals, "test-api-images-history:latest")
145
+}