Browse code

Correct the message of ErrorCodeNoSuchContainer to "No such container"

Fixes issue #18424

Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>

Wen Cheng Ma authored on 2015/12/04 16:00:08
Showing 7 changed files
... ...
@@ -367,7 +367,7 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW
367 367
 	if err := s.backend.ContainerRm(name, config); err != nil {
368 368
 		// Force a 404 for the empty string
369 369
 		if strings.Contains(strings.ToLower(err.Error()), "prefix can't be empty") {
370
-			return fmt.Errorf("no such id: \"\"")
370
+			return fmt.Errorf("no such container: \"\"")
371 371
 		}
372 372
 		return err
373 373
 	}
... ...
@@ -31,7 +31,7 @@ func (s *containerRouter) postContainersCopy(ctx context.Context, w http.Respons
31 31
 
32 32
 	data, err := s.backend.ContainerCopy(vars["name"], cfg.Resource)
33 33
 	if err != nil {
34
-		if strings.Contains(strings.ToLower(err.Error()), "no such id") {
34
+		if strings.Contains(strings.ToLower(err.Error()), "no such container") {
35 35
 			w.WriteHeader(http.StatusNotFound)
36 36
 			return nil
37 37
 		}
... ...
@@ -14,7 +14,7 @@ var (
14 14
 	// name or ID and we can't find it.
15 15
 	ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
16 16
 		Value:          "NOSUCHCONTAINER",
17
-		Message:        "no such id: %s",
17
+		Message:        "No such container: %s",
18 18
 		Description:    "The specified container can not be found",
19 19
 		HTTPStatusCode: http.StatusNotFound,
20 20
 	})
... ...
@@ -70,7 +70,7 @@ func (s *DockerSuite) TestPostContainersAttachContainerNotFound(c *check.C) {
70 70
 	status, body, err := sockRequest("POST", "/containers/doesnotexist/attach", nil)
71 71
 	c.Assert(status, checker.Equals, http.StatusNotFound)
72 72
 	c.Assert(err, checker.IsNil)
73
-	expected := "no such id: doesnotexist\n"
73
+	expected := "No such container: doesnotexist\n"
74 74
 	c.Assert(string(body), checker.Contains, expected)
75 75
 }
76 76
 
... ...
@@ -78,7 +78,7 @@ func (s *DockerSuite) TestGetContainersWsAttachContainerNotFound(c *check.C) {
78 78
 	status, body, err := sockRequest("GET", "/containers/doesnotexist/attach/ws", nil)
79 79
 	c.Assert(status, checker.Equals, http.StatusNotFound)
80 80
 	c.Assert(err, checker.IsNil)
81
-	expected := "no such id: doesnotexist\n"
81
+	expected := "No such container: doesnotexist\n"
82 82
 	c.Assert(string(body), checker.Contains, expected)
83 83
 }
84 84
 
... ...
@@ -1051,7 +1051,7 @@ func (s *DockerSuite) TestContainerApiDeleteNotExist(c *check.C) {
1051 1051
 	status, body, err := sockRequest("DELETE", "/containers/doesnotexist", nil)
1052 1052
 	c.Assert(err, checker.IsNil)
1053 1053
 	c.Assert(status, checker.Equals, http.StatusNotFound)
1054
-	c.Assert(string(body), checker.Matches, "no such id: doesnotexist\n")
1054
+	c.Assert(string(body), checker.Matches, "No such container: doesnotexist\n")
1055 1055
 }
1056 1056
 
1057 1057
 func (s *DockerSuite) TestContainerApiDeleteForce(c *check.C) {
... ...
@@ -348,6 +348,6 @@ func (s *DockerSuite) TestLogsFollowGoroutinesNoOutput(c *check.C) {
348 348
 func (s *DockerSuite) TestLogsCLIContainerNotFound(c *check.C) {
349 349
 	name := "testlogsnocontainer"
350 350
 	out, _, _ := dockerCmdWithError("logs", name)
351
-	message := fmt.Sprintf(".*no such id: %s.*\n", name)
351
+	message := fmt.Sprintf(".*No such container: %s.*\n", name)
352 352
 	c.Assert(out, checker.Matches, message)
353 353
 }
... ...
@@ -44,11 +44,11 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
44 44
 
45 45
 	out, _, err := dockerCmdWithError("stats", "notfound")
46 46
 	c.Assert(err, checker.NotNil)
47
-	c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out))
47
+	c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats, got %q instead", out))
48 48
 
49 49
 	out, _, err = dockerCmdWithError("stats", "--no-stream", "notfound")
50 50
 	c.Assert(err, checker.NotNil)
51
-	c.Assert(out, checker.Contains, "no such id: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out))
51
+	c.Assert(out, checker.Contains, "No such container: notfound", check.Commentf("Expected to fail on not found container stats with --no-stream, got %q instead", out))
52 52
 }
53 53
 
54 54
 func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {