Browse code

Improve sockRequest and sockRequestRaw check

Signed-off-by: Quentin Tayssier <qtayssier@gmail.com>

Quentin Tayssier authored on 2015/07/13 21:49:08
Showing 1 changed files
... ...
@@ -33,8 +33,8 @@ func (s *DockerSuite) TestContainerApiGetAll(c *check.C) {
33 33
 	}
34 34
 
35 35
 	status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
36
-	c.Assert(status, check.Equals, http.StatusOK)
37 36
 	c.Assert(err, check.IsNil)
37
+	c.Assert(status, check.Equals, http.StatusOK)
38 38
 
39 39
 	var inspectJSON []struct {
40 40
 		Names []string
... ...
@@ -59,8 +59,8 @@ func (s *DockerSuite) TestContainerApiGetJSONNoFieldsOmitted(c *check.C) {
59 59
 	c.Assert(err, check.IsNil)
60 60
 
61 61
 	status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
62
-	c.Assert(status, check.Equals, http.StatusOK)
63 62
 	c.Assert(err, check.IsNil)
63
+	c.Assert(status, check.Equals, http.StatusOK)
64 64
 
65 65
 	// empty Labels field triggered this bug, make sense to check for everything
66 66
 	// cause even Ports for instance can trigger this bug
... ...
@@ -99,8 +99,8 @@ func (s *DockerSuite) TestContainerPsOmitFields(c *check.C) {
99 99
 	c.Assert(err, check.IsNil)
100 100
 
101 101
 	status, body, err := sockRequest("GET", "/containers/json?all=1", nil)
102
-	c.Assert(status, check.Equals, http.StatusOK)
103 102
 	c.Assert(err, check.IsNil)
103
+	c.Assert(status, check.Equals, http.StatusOK)
104 104
 
105 105
 	var resp []containerPs
106 106
 	err = json.Unmarshal(body, &resp)
... ...
@@ -133,8 +133,8 @@ func (s *DockerSuite) TestContainerApiGetExport(c *check.C) {
133 133
 	}
134 134
 
135 135
 	status, body, err := sockRequest("GET", "/containers/"+name+"/export", nil)
136
-	c.Assert(status, check.Equals, http.StatusOK)
137 136
 	c.Assert(err, check.IsNil)
137
+	c.Assert(status, check.Equals, http.StatusOK)
138 138
 
139 139
 	found := false
140 140
 	for tarReader := tar.NewReader(bytes.NewReader(body)); ; {
... ...
@@ -165,8 +165,8 @@ func (s *DockerSuite) TestContainerApiGetChanges(c *check.C) {
165 165
 	}
166 166
 
167 167
 	status, body, err := sockRequest("GET", "/containers/"+name+"/changes", nil)
168
-	c.Assert(status, check.Equals, http.StatusOK)
169 168
 	c.Assert(err, check.IsNil)
169
+	c.Assert(status, check.Equals, http.StatusOK)
170 170
 
171 171
 	changes := []struct {
172 172
 		Kind int
... ...
@@ -196,16 +196,16 @@ func (s *DockerSuite) TestContainerApiStartVolumeBinds(c *check.C) {
196 196
 	}
197 197
 
198 198
 	status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
199
-	c.Assert(status, check.Equals, http.StatusCreated)
200 199
 	c.Assert(err, check.IsNil)
200
+	c.Assert(status, check.Equals, http.StatusCreated)
201 201
 
202 202
 	bindPath := randomUnixTmpDirPath("test")
203 203
 	config = map[string]interface{}{
204 204
 		"Binds": []string{bindPath + ":/tmp"},
205 205
 	}
206 206
 	status, _, err = sockRequest("POST", "/containers/"+name+"/start", config)
207
-	c.Assert(status, check.Equals, http.StatusNoContent)
208 207
 	c.Assert(err, check.IsNil)
208
+	c.Assert(status, check.Equals, http.StatusNoContent)
209 209
 
210 210
 	pth, err := inspectFieldMap(name, "Volumes", "/tmp")
211 211
 	if err != nil {
... ...
@@ -226,8 +226,8 @@ func (s *DockerSuite) TestContainerApiStartDupVolumeBinds(c *check.C) {
226 226
 	}
227 227
 
228 228
 	status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
229
-	c.Assert(status, check.Equals, http.StatusCreated)
230 229
 	c.Assert(err, check.IsNil)
230
+	c.Assert(status, check.Equals, http.StatusCreated)
231 231
 
232 232
 	bindPath1 := randomUnixTmpDirPath("test1")
233 233
 	bindPath2 := randomUnixTmpDirPath("test2")
... ...
@@ -236,8 +236,8 @@ func (s *DockerSuite) TestContainerApiStartDupVolumeBinds(c *check.C) {
236 236
 		"Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"},
237 237
 	}
238 238
 	status, body, err := sockRequest("POST", "/containers/"+name+"/start", config)
239
-	c.Assert(status, check.Equals, http.StatusInternalServerError)
240 239
 	c.Assert(err, check.IsNil)
240
+	c.Assert(status, check.Equals, http.StatusInternalServerError)
241 241
 
242 242
 	if !strings.Contains(string(body), "Duplicate bind") {
243 243
 		c.Fatalf("Expected failure due to duplicate bind mounts to same path, instead got: %q with error: %v", string(body), err)
... ...
@@ -259,15 +259,15 @@ func (s *DockerSuite) TestContainerApiStartVolumesFrom(c *check.C) {
259 259
 	}
260 260
 
261 261
 	status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
262
-	c.Assert(status, check.Equals, http.StatusCreated)
263 262
 	c.Assert(err, check.IsNil)
263
+	c.Assert(status, check.Equals, http.StatusCreated)
264 264
 
265 265
 	config = map[string]interface{}{
266 266
 		"VolumesFrom": []string{volName},
267 267
 	}
268 268
 	status, _, err = sockRequest("POST", "/containers/"+name+"/start", config)
269
-	c.Assert(status, check.Equals, http.StatusNoContent)
270 269
 	c.Assert(err, check.IsNil)
270
+	c.Assert(status, check.Equals, http.StatusNoContent)
271 271
 
272 272
 	pth, err := inspectFieldMap(name, "Volumes", volPath)
273 273
 	if err != nil {
... ...
@@ -461,8 +461,8 @@ func (s *DockerSuite) TestGetStoppedContainerStats(c *check.C) {
461 461
 		// We'll never get return for GET stats from sockRequest as of now,
462 462
 		// just send request and see if panic or error would happen on daemon side.
463 463
 		status, _, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
464
-		c.Assert(status, check.Equals, http.StatusOK)
465 464
 		c.Assert(err, check.IsNil)
465
+		c.Assert(status, check.Equals, http.StatusOK)
466 466
 	}()
467 467
 
468 468
 	// allow some time to send request and let daemon deal with it
... ...
@@ -491,8 +491,8 @@ func (s *DockerSuite) TestBuildApiDockerfilePath(c *check.C) {
491 491
 	}
492 492
 
493 493
 	res, body, err := sockRequestRaw("POST", "/build?dockerfile=../Dockerfile", buffer, "application/x-tar")
494
-	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
495 494
 	c.Assert(err, check.IsNil)
495
+	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
496 496
 
497 497
 	out, err := readBody(body)
498 498
 	if err != nil {
... ...
@@ -517,8 +517,8 @@ RUN find /tmp/`,
517 517
 	defer server.Close()
518 518
 
519 519
 	res, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json")
520
-	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
521 520
 	c.Assert(err, check.IsNil)
521
+	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
522 522
 
523 523
 	buf, err := readBody(body)
524 524
 	if err != nil {
... ...
@@ -630,8 +630,8 @@ RUN echo from dockerfile`,
630 630
 	defer git.Close()
631 631
 
632 632
 	res, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
633
-	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
634 633
 	c.Assert(err, check.IsNil)
634
+	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
635 635
 
636 636
 	buf, err := readBody(body)
637 637
 	if err != nil {
... ...
@@ -658,8 +658,8 @@ RUN echo from Dockerfile`,
658 658
 
659 659
 	// Make sure it tries to 'dockerfile' query param value
660 660
 	res, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json")
661
-	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
662 661
 	c.Assert(err, check.IsNil)
662
+	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
663 663
 
664 664
 	buf, err := readBody(body)
665 665
 	if err != nil {
... ...
@@ -687,8 +687,8 @@ RUN echo from dockerfile`,
687 687
 
688 688
 	// Make sure it tries to 'dockerfile' query param value
689 689
 	res, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
690
-	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
691 690
 	c.Assert(err, check.IsNil)
691
+	c.Assert(res.StatusCode, check.Equals, http.StatusOK)
692 692
 
693 693
 	buf, err := readBody(body)
694 694
 	if err != nil {
... ...
@@ -720,8 +720,8 @@ func (s *DockerSuite) TestBuildApiDockerfileSymlink(c *check.C) {
720 720
 	}
721 721
 
722 722
 	res, body, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar")
723
-	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
724 723
 	c.Assert(err, check.IsNil)
724
+	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
725 725
 
726 726
 	out, err := readBody(body)
727 727
 	if err != nil {
... ...
@@ -756,8 +756,8 @@ func (s *DockerSuite) TestPostContainerBindNormalVolume(c *check.C) {
756 756
 
757 757
 	bindSpec := map[string][]string{"Binds": {fooDir + ":/foo"}}
758 758
 	status, _, err := sockRequest("POST", "/containers/two/start", bindSpec)
759
-	c.Assert(status, check.Equals, http.StatusNoContent)
760 759
 	c.Assert(err, check.IsNil)
760
+	c.Assert(status, check.Equals, http.StatusNoContent)
761 761
 
762 762
 	fooDir2, err := inspectFieldMap("two", "Volumes", "/foo")
763 763
 	if err != nil {
... ...
@@ -780,8 +780,8 @@ func (s *DockerSuite) TestContainerApiPause(c *check.C) {
780 780
 	ContainerID := strings.TrimSpace(out)
781 781
 
782 782
 	status, _, err := sockRequest("POST", "/containers/"+ContainerID+"/pause", nil)
783
-	c.Assert(status, check.Equals, http.StatusNoContent)
784 783
 	c.Assert(err, check.IsNil)
784
+	c.Assert(status, check.Equals, http.StatusNoContent)
785 785
 
786 786
 	pausedContainers, err := getSliceOfPausedContainers()
787 787
 
... ...
@@ -794,8 +794,8 @@ func (s *DockerSuite) TestContainerApiPause(c *check.C) {
794 794
 	}
795 795
 
796 796
 	status, _, err = sockRequest("POST", "/containers/"+ContainerID+"/unpause", nil)
797
-	c.Assert(status, check.Equals, http.StatusNoContent)
798 797
 	c.Assert(err, check.IsNil)
798
+	c.Assert(status, check.Equals, http.StatusNoContent)
799 799
 
800 800
 	pausedContainers, err = getSliceOfPausedContainers()
801 801
 
... ...
@@ -824,8 +824,8 @@ func (s *DockerSuite) TestContainerApiTop(c *check.C) {
824 824
 	}
825 825
 	var top topResp
826 826
 	status, b, err := sockRequest("GET", "/containers/"+id+"/top?ps_args=aux", nil)
827
-	c.Assert(status, check.Equals, http.StatusOK)
828 827
 	c.Assert(err, check.IsNil)
828
+	c.Assert(status, check.Equals, http.StatusOK)
829 829
 
830 830
 	if err := json.Unmarshal(b, &top); err != nil {
831 831
 		c.Fatal(err)
... ...
@@ -858,8 +858,8 @@ func (s *DockerSuite) TestContainerApiCommit(c *check.C) {
858 858
 
859 859
 	name := "TestContainerApiCommit"
860 860
 	status, b, err := sockRequest("POST", "/commit?repo="+name+"&testtag=tag&container="+cName, nil)
861
-	c.Assert(status, check.Equals, http.StatusCreated)
862 861
 	c.Assert(err, check.IsNil)
862
+	c.Assert(status, check.Equals, http.StatusCreated)
863 863
 
864 864
 	type resp struct {
865 865
 		Id string
... ...
@@ -896,8 +896,8 @@ func (s *DockerSuite) TestContainerApiCommitWithLabelInConfig(c *check.C) {
896 896
 
897 897
 	name := "TestContainerApiCommitWithConfig"
898 898
 	status, b, err := sockRequest("POST", "/commit?repo="+name+"&container="+cName, config)
899
-	c.Assert(status, check.Equals, http.StatusCreated)
900 899
 	c.Assert(err, check.IsNil)
900
+	c.Assert(status, check.Equals, http.StatusCreated)
901 901
 
902 902
 	type resp struct {
903 903
 		Id string
... ...
@@ -941,8 +941,8 @@ func (s *DockerSuite) TestContainerApiCreate(c *check.C) {
941 941
 	}
942 942
 
943 943
 	status, b, err := sockRequest("POST", "/containers/create", config)
944
-	c.Assert(status, check.Equals, http.StatusCreated)
945 944
 	c.Assert(err, check.IsNil)
945
+	c.Assert(status, check.Equals, http.StatusCreated)
946 946
 
947 947
 	type createResp struct {
948 948
 		Id string
... ...
@@ -1148,8 +1148,8 @@ func (s *DockerSuite) TestContainerApiInvalidPortSyntax(c *check.C) {
1148 1148
 				}`
1149 1149
 
1150 1150
 	res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
1151
-	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
1152 1151
 	c.Assert(err, check.IsNil)
1152
+	c.Assert(res.StatusCode, check.Equals, http.StatusInternalServerError)
1153 1153
 
1154 1154
 	b, err := readBody(body)
1155 1155
 	if err != nil {
... ...
@@ -1185,8 +1185,8 @@ func (s *DockerSuite) TestContainerApiPostCreateNull(c *check.C) {
1185 1185
 		"OnBuild":null}`
1186 1186
 
1187 1187
 	res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
1188
-	c.Assert(res.StatusCode, check.Equals, http.StatusCreated)
1189 1188
 	c.Assert(err, check.IsNil)
1189
+	c.Assert(res.StatusCode, check.Equals, http.StatusCreated)
1190 1190
 
1191 1191
 	b, err := readBody(body)
1192 1192
 	if err != nil {
... ...
@@ -1229,7 +1229,8 @@ func (s *DockerSuite) TestCreateWithTooLowMemoryLimit(c *check.C) {
1229 1229
 		"Memory":    524287
1230 1230
 	}`
1231 1231
 
1232
-	res, body, _ := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
1232
+	res, body, err := sockRequestRaw("POST", "/containers/create", strings.NewReader(config), "application/json")
1233
+	c.Assert(err, check.IsNil)
1233 1234
 	b, err2 := readBody(body)
1234 1235
 	if err2 != nil {
1235 1236
 		c.Fatal(err2)
... ...
@@ -1252,7 +1253,8 @@ func (s *DockerSuite) TestStartWithTooLowMemoryLimit(c *check.C) {
1252 1252
                 "Memory":    524287
1253 1253
         }`
1254 1254
 
1255
-	res, body, _ := sockRequestRaw("POST", "/containers/"+containerID+"/start", strings.NewReader(config), "application/json")
1255
+	res, body, err := sockRequestRaw("POST", "/containers/"+containerID+"/start", strings.NewReader(config), "application/json")
1256
+	c.Assert(err, check.IsNil)
1256 1257
 	b, err2 := readBody(body)
1257 1258
 	if err2 != nil {
1258 1259
 		c.Fatal(err2)
... ...
@@ -1270,10 +1272,9 @@ func (s *DockerSuite) TestContainerApiRename(c *check.C) {
1270 1270
 	containerID := strings.TrimSpace(out)
1271 1271
 	newName := "TestContainerApiRenameNew"
1272 1272
 	statusCode, _, err := sockRequest("POST", "/containers/"+containerID+"/rename?name="+newName, nil)
1273
-
1273
+	c.Assert(err, check.IsNil)
1274 1274
 	// 204 No Content is expected, not 200
1275 1275
 	c.Assert(statusCode, check.Equals, http.StatusNoContent)
1276
-	c.Assert(err, check.IsNil)
1277 1276
 
1278 1277
 	name, err := inspectField(containerID, "Name")
1279 1278
 	if name != "/"+newName {
... ...
@@ -1290,8 +1291,8 @@ func (s *DockerSuite) TestContainerApiKill(c *check.C) {
1290 1290
 	}
1291 1291
 
1292 1292
 	status, _, err := sockRequest("POST", "/containers/"+name+"/kill", nil)
1293
-	c.Assert(status, check.Equals, http.StatusNoContent)
1294 1293
 	c.Assert(err, check.IsNil)
1294
+	c.Assert(status, check.Equals, http.StatusNoContent)
1295 1295
 
1296 1296
 	state, err := inspectField(name, "State.Running")
1297 1297
 	if err != nil {
... ...
@@ -1311,8 +1312,8 @@ func (s *DockerSuite) TestContainerApiRestart(c *check.C) {
1311 1311
 	}
1312 1312
 
1313 1313
 	status, _, err := sockRequest("POST", "/containers/"+name+"/restart?t=1", nil)
1314
-	c.Assert(status, check.Equals, http.StatusNoContent)
1315 1314
 	c.Assert(err, check.IsNil)
1315
+	c.Assert(status, check.Equals, http.StatusNoContent)
1316 1316
 
1317 1317
 	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5); err != nil {
1318 1318
 		c.Fatal(err)
... ...
@@ -1330,8 +1331,8 @@ func (s *DockerSuite) TestContainerApiRestartNotimeoutParam(c *check.C) {
1330 1330
 	c.Assert(waitRun(id), check.IsNil)
1331 1331
 
1332 1332
 	status, _, err := sockRequest("POST", "/containers/"+name+"/restart", nil)
1333
-	c.Assert(status, check.Equals, http.StatusNoContent)
1334 1333
 	c.Assert(err, check.IsNil)
1334
+	c.Assert(status, check.Equals, http.StatusNoContent)
1335 1335
 
1336 1336
 	if err := waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5); err != nil {
1337 1337
 		c.Fatal(err)
... ...
@@ -1347,18 +1348,18 @@ func (s *DockerSuite) TestContainerApiStart(c *check.C) {
1347 1347
 	}
1348 1348
 
1349 1349
 	status, _, err := sockRequest("POST", "/containers/create?name="+name, config)
1350
-	c.Assert(status, check.Equals, http.StatusCreated)
1351 1350
 	c.Assert(err, check.IsNil)
1351
+	c.Assert(status, check.Equals, http.StatusCreated)
1352 1352
 
1353 1353
 	conf := make(map[string]interface{})
1354 1354
 	status, _, err = sockRequest("POST", "/containers/"+name+"/start", conf)
1355
-	c.Assert(status, check.Equals, http.StatusNoContent)
1356 1355
 	c.Assert(err, check.IsNil)
1356
+	c.Assert(status, check.Equals, http.StatusNoContent)
1357 1357
 
1358 1358
 	// second call to start should give 304
1359 1359
 	status, _, err = sockRequest("POST", "/containers/"+name+"/start", conf)
1360
-	c.Assert(status, check.Equals, http.StatusNotModified)
1361 1360
 	c.Assert(err, check.IsNil)
1361
+	c.Assert(status, check.Equals, http.StatusNotModified)
1362 1362
 }
1363 1363
 
1364 1364
 func (s *DockerSuite) TestContainerApiStop(c *check.C) {
... ...
@@ -1370,8 +1371,8 @@ func (s *DockerSuite) TestContainerApiStop(c *check.C) {
1370 1370
 	}
1371 1371
 
1372 1372
 	status, _, err := sockRequest("POST", "/containers/"+name+"/stop?t=1", nil)
1373
-	c.Assert(status, check.Equals, http.StatusNoContent)
1374 1373
 	c.Assert(err, check.IsNil)
1374
+	c.Assert(status, check.Equals, http.StatusNoContent)
1375 1375
 
1376 1376
 	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5); err != nil {
1377 1377
 		c.Fatal(err)
... ...
@@ -1379,8 +1380,8 @@ func (s *DockerSuite) TestContainerApiStop(c *check.C) {
1379 1379
 
1380 1380
 	// second call to start should give 304
1381 1381
 	status, _, err = sockRequest("POST", "/containers/"+name+"/stop?t=1", nil)
1382
-	c.Assert(status, check.Equals, http.StatusNotModified)
1383 1382
 	c.Assert(err, check.IsNil)
1383
+	c.Assert(status, check.Equals, http.StatusNotModified)
1384 1384
 }
1385 1385
 
1386 1386
 func (s *DockerSuite) TestContainerApiWait(c *check.C) {
... ...
@@ -1392,8 +1393,8 @@ func (s *DockerSuite) TestContainerApiWait(c *check.C) {
1392 1392
 	}
1393 1393
 
1394 1394
 	status, body, err := sockRequest("POST", "/containers/"+name+"/wait", nil)
1395
-	c.Assert(status, check.Equals, http.StatusOK)
1396 1395
 	c.Assert(err, check.IsNil)
1396
+	c.Assert(status, check.Equals, http.StatusOK)
1397 1397
 
1398 1398
 	if err := waitInspect(name, "{{ .State.Running  }}", "false", 5); err != nil {
1399 1399
 		c.Fatal(err)
... ...
@@ -1562,8 +1563,8 @@ func (s *DockerSuite) TestContainerApiDeleteConflict(c *check.C) {
1562 1562
 	c.Assert(waitRun(id), check.IsNil)
1563 1563
 
1564 1564
 	status, _, err := sockRequest("DELETE", "/containers/"+id, nil)
1565
-	c.Assert(status, check.Equals, http.StatusConflict)
1566 1565
 	c.Assert(err, check.IsNil)
1566
+	c.Assert(status, check.Equals, http.StatusConflict)
1567 1567
 }
1568 1568
 
1569 1569
 func (s *DockerSuite) TestContainerApiDeleteRemoveVolume(c *check.C) {
... ...
@@ -1583,8 +1584,8 @@ func (s *DockerSuite) TestContainerApiDeleteRemoveVolume(c *check.C) {
1583 1583
 	c.Assert(err, check.IsNil)
1584 1584
 
1585 1585
 	status, _, err := sockRequest("DELETE", "/containers/"+id+"?v=1&force=1", nil)
1586
-	c.Assert(status, check.Equals, http.StatusNoContent)
1587 1586
 	c.Assert(err, check.IsNil)
1587
+	c.Assert(status, check.Equals, http.StatusNoContent)
1588 1588
 
1589 1589
 	if _, err := os.Stat(vol); !os.IsNotExist(err) {
1590 1590
 		c.Fatalf("expected to get ErrNotExist error, got %v", err)
... ...
@@ -1651,10 +1652,9 @@ func (s *DockerSuite) TestPostContainerStop(c *check.C) {
1651 1651
 	c.Assert(waitRun(containerID), check.IsNil)
1652 1652
 
1653 1653
 	statusCode, _, err := sockRequest("POST", "/containers/"+containerID+"/stop", nil)
1654
-
1654
+	c.Assert(err, check.IsNil)
1655 1655
 	// 204 No Content is expected, not 200
1656 1656
 	c.Assert(statusCode, check.Equals, http.StatusNoContent)
1657
-	c.Assert(err, check.IsNil)
1658 1657
 
1659 1658
 	if err := waitInspect(containerID, "{{ .State.Running  }}", "false", 5); err != nil {
1660 1659
 		c.Fatal(err)