mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Use stderr instead of logrus for CLI error messages
Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
@@ -4808,7 +4808,7 @@ func (s *DockerSuite) TestBuildRenamedDockerfile(c *check.C) {
|
||||
c.Fatalf("test5 was supposed to fail to find passwd")
|
||||
}
|
||||
|
||||
if expected := fmt.Sprintf("The Dockerfile (%s) must be within the build context (.)", strings.Replace(nonDockerfileFile, `\`, `\\`, -1)); !strings.Contains(out, expected) {
|
||||
if expected := fmt.Sprintf("The Dockerfile (%s) must be within the build context (.)", nonDockerfileFile); !strings.Contains(out, expected) {
|
||||
c.Fatalf("wrong error messsage:%v\nexpected to contain=%v", out, expected)
|
||||
}
|
||||
|
||||
@@ -5404,7 +5404,7 @@ func (s *DockerSuite) TestBuildBadCmdFlag(c *check.C) {
|
||||
c.Fatal("Build should have failed")
|
||||
}
|
||||
|
||||
exp := `"Unknown flag: boo"`
|
||||
exp := "\nUnknown flag: boo\n"
|
||||
if !strings.Contains(out, exp) {
|
||||
c.Fatalf("Bad output\nGot:%s\n\nExpected to contain:%s\n", out, exp)
|
||||
}
|
||||
@@ -5421,7 +5421,7 @@ func (s *DockerSuite) TestBuildRUNErrMsg(c *check.C) {
|
||||
c.Fatal("Should have failed to build")
|
||||
}
|
||||
|
||||
exp := "The command '/bin/sh -c badEXE a1 \\\\& a2\\ta3' returned a non-zero code: 127"
|
||||
exp := `The command '/bin/sh -c badEXE a1 \& a2 a3' returned a non-zero code: 127`
|
||||
if !strings.Contains(out, exp) {
|
||||
c.Fatalf("RUN doesn't have the correct output:\nGot:%s\nExpected:%s", out, exp)
|
||||
}
|
||||
|
||||
@@ -907,8 +907,8 @@ func (s *DockerDaemonSuite) TestDaemonLoggingDriverNoneLogsError(c *check.C) {
|
||||
if err == nil {
|
||||
c.Fatalf("Logs should fail with \"none\" driver")
|
||||
}
|
||||
if !strings.Contains(out, `\"logs\" command is supported only for \"json-file\" logging driver`) {
|
||||
c.Fatalf("There should be error about non-json-file driver, got %s", out)
|
||||
if !strings.Contains(out, `"logs" command is supported only for "json-file" logging driver`) {
|
||||
c.Fatalf("There should be error about non-json-file driver, got: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,3 +152,32 @@ func (s *DockerSuite) TestHelpTextVerify(c *check.C) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestHelpErrorStderr(c *check.C) {
|
||||
// If we had a generic CLI test file this one shoudl go in there
|
||||
|
||||
cmd := exec.Command(dockerBinary, "boogie")
|
||||
out, ec, err := runCommandWithOutput(cmd)
|
||||
if err == nil || ec == 0 {
|
||||
c.Fatalf("Boogie command should have failed")
|
||||
}
|
||||
|
||||
expected := "docker: 'boogie' is not a docker command. See 'docker --help'.\n"
|
||||
if out != expected {
|
||||
c.Fatalf("Bad output from boogie\nGot:%s\nExpected:%s", out, expected)
|
||||
}
|
||||
|
||||
cmd = exec.Command(dockerBinary, "rename", "foo", "bar")
|
||||
out, ec, err = runCommandWithOutput(cmd)
|
||||
if err == nil || ec == 0 {
|
||||
c.Fatalf("Rename should have failed")
|
||||
}
|
||||
|
||||
expected = `Error response from daemon: no such id: foo
|
||||
Error: failed to rename container named foo
|
||||
`
|
||||
if out != expected {
|
||||
c.Fatalf("Bad output from rename\nGot:%s\nExpected:%s", out, expected)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2051,7 +2051,7 @@ func (s *DockerSuite) TestRunWithBadDevice(c *check.C) {
|
||||
if err == nil {
|
||||
c.Fatal("Run should fail with bad device")
|
||||
}
|
||||
expected := `\"/etc\": not a device node`
|
||||
expected := `"/etc": not a device node`
|
||||
if !strings.Contains(out, expected) {
|
||||
c.Fatalf("Output should contain %q, actual out: %q", expected, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user