From 2910f1101df088c20d22c1adf00c1c3ceb382ddf Mon Sep 17 00:00:00 2001 From: Mohammed Aaqib Ansari Date: Mon, 19 Oct 2015 22:56:29 -0400 Subject: [PATCH] Using checkers assert for integration-cli/docker_cli_events_test.go Signed-off-by: Mohammed Aaqib Ansari --- integration-cli/docker_cli_events_test.go | 256 +++++++--------------- 1 file changed, 74 insertions(+), 182 deletions(-) diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index c067faf43d..f33f8434bb 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -39,12 +39,8 @@ func (s *DockerSuite) TestEventsTimestampFormats(c *check.C) { since, until := f(start), f(end) out, _ := dockerCmd(c, "events", "--since="+since, "--until="+until) events := strings.Split(strings.TrimSpace(out), "\n") - if len(events) != 2 { - c.Fatalf("unexpected events, was expecting only 2 events tag/untag (since=%s, until=%s) out=%s", since, until, out) - } - if !strings.Contains(out, "untag") { - c.Fatalf("expected 'untag' event not found (since=%s, until=%s) out=%s", since, until, out) - } + c.Assert(events, checker.HasLen, 2, check.Commentf("unexpected events, was expecting only 2 events tag/untag (since=%s, until=%s) out=%s", since, until, out)) + c.Assert(out, checker.Contains, "untag", check.Commentf("expected 'untag' event not found (since=%s, until=%s)", since, until)) } } @@ -58,18 +54,15 @@ func (s *DockerSuite) TestEventsUntag(c *check.C) { dockerCmd(c, "rmi", "utest:tag2") eventsCmd := exec.Command(dockerBinary, "events", "--since=1") out, exitCode, _, err := runCommandWithOutputForDuration(eventsCmd, time.Duration(time.Millisecond*200)) - if exitCode != 0 || err != nil { - c.Fatalf("Failed to get events - exit code %d: %s", exitCode, err) - } + c.Assert(err, checker.IsNil) + c.Assert(exitCode, checker.Equals, 0, check.Commentf("Failed to get events")) events := strings.Split(out, "\n") nEvents := len(events) // The last element after the split above will be an empty string, so we // get the two elements before the last, which are the untags we're // looking for. for _, v := range events[nEvents-3 : nEvents-1] { - if !strings.Contains(v, "untag") { - c.Fatalf("event should be untag, not %#v", v) - } + c.Assert(v, checker.Contains, "untag", check.Commentf("event should be untag")) } } @@ -77,25 +70,18 @@ func (s *DockerSuite) TestEventsContainerFailStartDie(c *check.C) { out, _ := dockerCmd(c, "images", "-q") image := strings.Split(out, "\n")[0] - if _, _, err := dockerCmdWithError("run", "--name", "testeventdie", image, "blerg"); err == nil { - c.Fatalf("Container run with command blerg should have failed, but it did not") - } + _, _, err := dockerCmdWithError("run", "--name", "testeventdie", image, "blerg") + c.Assert(err, checker.NotNil, check.Commentf("Container run with command blerg should have failed, but it did not, out=%s", out)) out, _ = dockerCmd(c, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(out, "\n") - if len(events) <= 1 { - c.Fatalf("Missing expected event") - } + c.Assert(len(events), checker.GreaterThan, 1) //Missing expected event startEvent := strings.Fields(events[len(events)-3]) dieEvent := strings.Fields(events[len(events)-2]) - if startEvent[len(startEvent)-1] != "start" { - c.Fatalf("event should be start, not %#v", startEvent) - } - if dieEvent[len(dieEvent)-1] != "die" { - c.Fatalf("event should be die, not %#v", dieEvent) - } + c.Assert(startEvent[len(startEvent)-1], checker.Equals, "start", check.Commentf("event should be start, not %#v", startEvent)) + c.Assert(dieEvent[len(dieEvent)-1], checker.Equals, "die", check.Commentf("event should be die, not %#v", dieEvent)) } @@ -117,17 +103,13 @@ func (s *DockerSuite) TestEventsLimit(c *check.C) { close(errChan) for err := range errChan { - if err != nil { - c.Fatalf("%q failed with error: %v", strings.Join(args, " "), err) - } + c.Assert(err, checker.IsNil, check.Commentf("%q failed with error", strings.Join(args, " "))) } out, _ := dockerCmd(c, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(out, "\n") nEvents := len(events) - 1 - if nEvents != 64 { - c.Fatalf("events should be limited to 64, but received %d", nEvents) - } + c.Assert(nEvents, checker.Equals, 64, check.Commentf("events should be limited to 64, but received %d", nEvents)) } func (s *DockerSuite) TestEventsContainerEvents(c *check.C) { @@ -136,29 +118,17 @@ func (s *DockerSuite) TestEventsContainerEvents(c *check.C) { out, _ := dockerCmd(c, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(out, "\n") events = events[:len(events)-1] - if len(events) < 5 { - c.Fatalf("Missing expected event") - } + c.Assert(len(events), checker.GreaterOrEqualThan, 5) //Missing expected event createEvent := strings.Fields(events[len(events)-5]) attachEvent := strings.Fields(events[len(events)-4]) startEvent := strings.Fields(events[len(events)-3]) dieEvent := strings.Fields(events[len(events)-2]) destroyEvent := strings.Fields(events[len(events)-1]) - if createEvent[len(createEvent)-1] != "create" { - c.Fatalf("event should be create, not %#v", createEvent) - } - if attachEvent[len(attachEvent)-1] != "attach" { - c.Fatalf("event should be attach, not %#v", attachEvent) - } - if startEvent[len(startEvent)-1] != "start" { - c.Fatalf("event should be start, not %#v", startEvent) - } - if dieEvent[len(dieEvent)-1] != "die" { - c.Fatalf("event should be die, not %#v", dieEvent) - } - if destroyEvent[len(destroyEvent)-1] != "destroy" { - c.Fatalf("event should be destroy, not %#v", destroyEvent) - } + c.Assert(createEvent[len(createEvent)-1], checker.Equals, "create", check.Commentf("event should be create, not %#v", createEvent)) + c.Assert(attachEvent[len(attachEvent)-1], checker.Equals, "attach", check.Commentf("event should be attach, not %#v", attachEvent)) + c.Assert(startEvent[len(startEvent)-1], checker.Equals, "start", check.Commentf("event should be start, not %#v", startEvent)) + c.Assert(dieEvent[len(dieEvent)-1], checker.Equals, "die", check.Commentf("event should be die, not %#v", dieEvent)) + c.Assert(destroyEvent[len(destroyEvent)-1], checker.Equals, "destroy", check.Commentf("event should be destroy, not %#v", destroyEvent)) } @@ -171,29 +141,17 @@ func (s *DockerSuite) TestEventsContainerEventsSinceUnixEpoch(c *check.C) { fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(out, "\n") events = events[:len(events)-1] - if len(events) < 5 { - c.Fatalf("Missing expected event") - } + c.Assert(len(events), checker.GreaterOrEqualThan, 5) //Missing expected event createEvent := strings.Fields(events[len(events)-5]) attachEvent := strings.Fields(events[len(events)-4]) startEvent := strings.Fields(events[len(events)-3]) dieEvent := strings.Fields(events[len(events)-2]) destroyEvent := strings.Fields(events[len(events)-1]) - if createEvent[len(createEvent)-1] != "create" { - c.Fatalf("event should be create, not %#v", createEvent) - } - if attachEvent[len(attachEvent)-1] != "attach" { - c.Fatalf("event should be attach, not %#v", attachEvent) - } - if startEvent[len(startEvent)-1] != "start" { - c.Fatalf("event should be start, not %#v", startEvent) - } - if dieEvent[len(dieEvent)-1] != "die" { - c.Fatalf("event should be die, not %#v", dieEvent) - } - if destroyEvent[len(destroyEvent)-1] != "destroy" { - c.Fatalf("event should be destroy, not %#v", destroyEvent) - } + c.Assert(createEvent[len(createEvent)-1], checker.Equals, "create", check.Commentf("event should be create, not %#v", createEvent)) + c.Assert(attachEvent[len(attachEvent)-1], checker.Equals, "attach", check.Commentf("event should be attach, not %#v", attachEvent)) + c.Assert(startEvent[len(startEvent)-1], checker.Equals, "start", check.Commentf("event should be start, not %#v", startEvent)) + c.Assert(dieEvent[len(dieEvent)-1], checker.Equals, "die", check.Commentf("event should be die, not %#v", dieEvent)) + c.Assert(destroyEvent[len(destroyEvent)-1], checker.Equals, "destroy", check.Commentf("event should be destroy, not %#v", destroyEvent)) } @@ -204,27 +162,17 @@ func (s *DockerSuite) TestEventsImageUntagDelete(c *check.C) { `FROM scratch MAINTAINER "docker"`, true) - if err != nil { - c.Fatal(err) - } - if err := deleteImages(name); err != nil { - c.Fatal(err) - } + c.Assert(err, checker.IsNil) + c.Assert(deleteImages(name), checker.IsNil) out, _ := dockerCmd(c, "events", "--since=0", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(out, "\n") events = events[:len(events)-1] - if len(events) < 2 { - c.Fatalf("Missing expected event") - } + c.Assert(len(events), checker.GreaterOrEqualThan, 2) //Missing expected event untagEvent := strings.Fields(events[len(events)-2]) deleteEvent := strings.Fields(events[len(events)-1]) - if untagEvent[len(untagEvent)-1] != "untag" { - c.Fatalf("untag should be untag, not %#v", untagEvent) - } - if deleteEvent[len(deleteEvent)-1] != "delete" { - c.Fatalf("delete should be delete, not %#v", deleteEvent) - } + c.Assert(untagEvent[len(untagEvent)-1], checker.Equals, "untag", check.Commentf("untag should be untag, not %#v", untagEvent)) + c.Assert(deleteEvent[len(deleteEvent)-1], checker.Equals, "delete", check.Commentf("untag should be delete, not %#v", untagEvent)) } func (s *DockerSuite) TestEventsImageTag(c *check.C) { @@ -239,15 +187,11 @@ func (s *DockerSuite) TestEventsImageTag(c *check.C) { fmt.Sprintf("--until=%d", daemonTime(c).Unix())) events := strings.Split(strings.TrimSpace(out), "\n") - if len(events) != 1 { - c.Fatalf("was expecting 1 event. out=%s", out) - } + c.Assert(events, checker.HasLen, 1, check.Commentf("was expecting 1 event. out=%s", out)) event := strings.TrimSpace(events[0]) expectedStr := image + ": tag" - if !strings.HasSuffix(event, expectedStr) { - c.Fatalf("wrong event format. expected='%s' got=%s", expectedStr, event) - } + c.Assert(event, checker.HasSuffix, expectedStr, check.Commentf("wrong event format. expected='%s' got=%s", expectedStr, event)) } @@ -265,9 +209,7 @@ func (s *DockerSuite) TestEventsImagePull(c *check.C) { events := strings.Split(strings.TrimSpace(out), "\n") event := strings.TrimSpace(events[len(events)-1]) - if !strings.HasSuffix(event, "hello-world:latest: pull") { - c.Fatalf("Missing pull event - got:%q", event) - } + c.Assert(event, checker.HasSuffix, "hello-world:latest: pull", check.Commentf("Missing pull event - got:%q", event)) } @@ -279,12 +221,8 @@ func (s *DockerSuite) TestEventsImageImport(c *check.C) { eventImport := make(chan struct{}) eventsCmd := exec.Command(dockerBinary, "events", "--since", strconv.FormatInt(since, 10)) stdout, err := eventsCmd.StdoutPipe() - if err != nil { - c.Fatal(err) - } - if err := eventsCmd.Start(); err != nil { - c.Fatal(err) - } + c.Assert(err, checker.IsNil) + c.Assert(eventsCmd.Start(), checker.IsNil) defer eventsCmd.Process.Kill() go func() { @@ -306,9 +244,7 @@ func (s *DockerSuite) TestEventsImageImport(c *check.C) { exec.Command(dockerBinary, "export", cleanedContainerID), exec.Command(dockerBinary, "import", "-"), ) - if err != nil { - c.Errorf("import failed with errors: %v, output: %q", err, out) - } + c.Assert(err, checker.IsNil, check.Commentf("import failed with output: %q", out)) newContainerID := strings.TrimSpace(out) id <- newContainerID @@ -328,9 +264,7 @@ func (s *DockerSuite) TestEventsFilters(c *check.C) { for _, event := range events { eventFields := strings.Fields(event) eventName := eventFields[len(eventFields)-1] - if ok, err := regexp.MatchString(match, eventName); err != nil || !ok { - c.Fatalf("event should match %s, got %#v, err: %v", match, eventFields, err) - } + c.Assert(eventName, checker.Matches, match) } } @@ -345,9 +279,7 @@ func (s *DockerSuite) TestEventsFilters(c *check.C) { // make sure we at least got 2 start events count := strings.Count(out, "start") - if count < 2 { - c.Fatalf("should have had 2 start events but had %d, out: %s", count, out) - } + c.Assert(strings.Count(out, "start"), checker.GreaterOrEqualThan, 2, check.Commentf("should have had 2 start events but had %d, out: %s", count, out)) } @@ -365,9 +297,7 @@ func (s *DockerSuite) TestEventsFilterImageName(c *check.C) { out, _ = dockerCmd(c, "events", fmt.Sprintf("--since=%d", since), fmt.Sprintf("--until=%d", daemonTime(c).Unix()), "--filter", fmt.Sprintf("image=%s", name)) events := strings.Split(out, "\n") events = events[:len(events)-1] - if len(events) == 0 { - c.Fatalf("Expected events but found none for the image busybox:latest") - } + c.Assert(events, checker.Not(checker.HasLen), 0) //Expected events but found none for the image busybox:latest count1 := 0 count2 := 0 @@ -378,9 +308,8 @@ func (s *DockerSuite) TestEventsFilterImageName(c *check.C) { count2++ } } - if count1 == 0 || count2 == 0 { - c.Fatalf("Expected events from each container but got %d from %s and %d from %s", count1, container1, count2, container2) - } + c.Assert(count1, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count1, container1)) + c.Assert(count2, checker.Not(checker.Equals), 0, check.Commentf("Expected event from container but got %d from %s", count2, container2)) } @@ -407,7 +336,7 @@ func (s *DockerSuite) TestEventsFilterLabels(c *check.C) { for _, e := range events { c.Assert(e, checker.Contains, container1) - c.Assert(e, check.Not(checker.Contains), container2) + c.Assert(e, checker.Not(checker.Contains), container2) } } @@ -421,9 +350,7 @@ func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) { _, err := buildImage(name, fmt.Sprintf(` FROM busybox:latest LABEL %s`, label), true) - if err != nil { - c.Fatalf("Couldn't create image: %q", err) - } + c.Assert(err, checker.IsNil, check.Commentf("Couldn't create image")) dockerCmd(c, "tag", name, "labelfiltertest:tag1") dockerCmd(c, "tag", name, "labelfiltertest:tag2") @@ -439,7 +366,7 @@ func (s *DockerSuite) TestEventsFilterImageLabels(c *check.C) { events := strings.Split(strings.TrimSpace(out), "\n") // 2 events from the "docker tag" command, another one is from "docker build" - c.Assert(len(events), checker.Equals, 3, check.Commentf("Events == %s", events)) + c.Assert(events, checker.HasLen, 3, check.Commentf("Events == %s", events)) for _, e := range events { c.Assert(e, checker.Contains, "labelfiltertest") } @@ -453,9 +380,7 @@ func (s *DockerSuite) TestEventsFilterContainer(c *check.C) { for _, name := range []string{"container_1", "container_2"} { dockerCmd(c, "run", "--name", name, "busybox", "true") id, err := inspectField(name, "Id") - if err != nil { - c.Fatal(err) - } + c.Assert(err, checker.IsNil) nameID[name] = id } @@ -484,16 +409,12 @@ func (s *DockerSuite) TestEventsFilterContainer(c *check.C) { // filter by names out, _ := dockerCmd(c, "events", "--since", since, "--until", until, "--filter", "container="+name) events := strings.Split(strings.TrimSuffix(out, "\n"), "\n") - if err := checkEvents(ID, events); err != nil { - c.Fatal(err) - } + c.Assert(checkEvents(ID, events), checker.IsNil) // filter by ID's out, _ = dockerCmd(c, "events", "--since", since, "--until", until, "--filter", "container="+ID) events = strings.Split(strings.TrimSuffix(out, "\n"), "\n") - if err := checkEvents(ID, events); err != nil { - c.Fatal(err) - } + c.Assert(checkEvents(ID, events), checker.IsNil) } } @@ -509,12 +430,8 @@ func (s *DockerSuite) TestEventsStreaming(c *check.C) { eventsCmd := exec.Command(dockerBinary, "events", "--since", strconv.FormatInt(start, 10)) stdout, err := eventsCmd.StdoutPipe() - if err != nil { - c.Fatal(err) - } - if err := eventsCmd.Start(); err != nil { - c.Fatalf("failed to start 'docker events': %s", err) - } + c.Assert(err, checker.IsNil) + c.Assert(eventsCmd.Start(), checker.IsNil, check.Commentf("failed to start 'docker events'")) defer eventsCmd.Process.Kill() go func() { @@ -581,15 +498,13 @@ func (s *DockerSuite) TestEventsCommit(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cID := strings.TrimSpace(out) - c.Assert(waitRun(cID), check.IsNil) + c.Assert(waitRun(cID), checker.IsNil) dockerCmd(c, "commit", "-m", "test", cID) dockerCmd(c, "stop", cID) out, _ = dockerCmd(c, "events", "--since=0", "-f", "container="+cID, "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " commit\n") { - c.Fatalf("Missing 'commit' log event\n%s", out) - } + c.Assert(out, checker.Contains, " commit\n", check.Commentf("Missing 'commit' log event")) } func (s *DockerSuite) TestEventsCopy(c *check.C) { @@ -600,36 +515,26 @@ func (s *DockerSuite) TestEventsCopy(c *check.C) { id, err := buildImage("cpimg", ` FROM busybox RUN echo HI > /tmp/file`, true) - if err != nil { - c.Fatalf("Couldn't create image: %q", err) - } + c.Assert(err, checker.IsNil, check.Commentf("Couldn't create image")) // Create an empty test file. tempFile, err := ioutil.TempFile("", "test-events-copy-") - if err != nil { - c.Fatal(err) - } + c.Assert(err, checker.IsNil) defer os.Remove(tempFile.Name()) - if err := tempFile.Close(); err != nil { - c.Fatal(err) - } + c.Assert(tempFile.Close(), checker.IsNil) dockerCmd(c, "create", "--name=cptest", id) dockerCmd(c, "cp", "cptest:/tmp/file", tempFile.Name()) out, _ := dockerCmd(c, "events", "--since=0", "-f", "container=cptest", "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " archive-path\n") { - c.Fatalf("Missing 'archive-path' log event\n%s", out) - } + c.Assert(out, checker.Contains, " archive-path\n", check.Commentf("Missing 'archive-path' log event\n")) dockerCmd(c, "cp", tempFile.Name(), "cptest:/tmp/filecopy") out, _ = dockerCmd(c, "events", "--since=0", "-f", "container=cptest", "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " extract-to-dir\n") { - c.Fatalf("Missing 'extract-to-dir' log event\n%s", out) - } + c.Assert(out, checker.Contains, " extract-to-dir\n", check.Commentf("Missing 'extract-to-dir' log event")) } func (s *DockerSuite) TestEventsResize(c *check.C) { @@ -638,19 +543,17 @@ func (s *DockerSuite) TestEventsResize(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cID := strings.TrimSpace(out) - c.Assert(waitRun(cID), check.IsNil) + c.Assert(waitRun(cID), checker.IsNil) endpoint := "/containers/" + cID + "/resize?h=80&w=24" status, _, err := sockRequest("POST", endpoint, nil) - c.Assert(status, check.Equals, http.StatusOK) - c.Assert(err, check.IsNil) + c.Assert(status, checker.Equals, http.StatusOK) + c.Assert(err, checker.IsNil) dockerCmd(c, "stop", cID) out, _ = dockerCmd(c, "events", "--since=0", "-f", "container="+cID, "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " resize\n") { - c.Fatalf("Missing 'resize' log event\n%s", out) - } + c.Assert(out, checker.Contains, " resize\n", check.Commentf("Missing 'resize' log event")) } func (s *DockerSuite) TestEventsAttach(c *check.C) { @@ -662,32 +565,27 @@ func (s *DockerSuite) TestEventsAttach(c *check.C) { cmd := exec.Command(dockerBinary, "attach", cID) stdin, err := cmd.StdinPipe() - c.Assert(err, check.IsNil) + c.Assert(err, checker.IsNil) defer stdin.Close() stdout, err := cmd.StdoutPipe() - c.Assert(err, check.IsNil) + c.Assert(err, checker.IsNil) defer stdout.Close() - c.Assert(cmd.Start(), check.IsNil) + c.Assert(cmd.Start(), checker.IsNil) defer cmd.Process.Kill() // Make sure we're done attaching by writing/reading some stuff - if _, err := stdin.Write([]byte("hello\n")); err != nil { - c.Fatal(err) - } + _, err = stdin.Write([]byte("hello\n")) + c.Assert(err, checker.IsNil) out, err = bufio.NewReader(stdout).ReadString('\n') - c.Assert(err, check.IsNil) - if strings.TrimSpace(out) != "hello" { - c.Fatalf("expected 'hello', got %q", out) - } + c.Assert(err, checker.IsNil) + c.Assert(strings.TrimSpace(out), checker.Equals, "hello", check.Commentf("expected 'hello'")) - c.Assert(stdin.Close(), check.IsNil) + c.Assert(stdin.Close(), checker.IsNil) dockerCmd(c, "stop", cID) out, _ = dockerCmd(c, "events", "--since=0", "-f", "container="+cID, "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " attach\n") { - c.Fatalf("Missing 'attach' log event\n%s", out) - } + c.Assert(out, checker.Contains, " attach\n", check.Commentf("Missing 'attach' log event")) } func (s *DockerSuite) TestEventsRename(c *check.C) { @@ -698,9 +596,7 @@ func (s *DockerSuite) TestEventsRename(c *check.C) { dockerCmd(c, "rename", "oldName", "newName") out, _ := dockerCmd(c, "events", "--since=0", "-f", "container=newName", "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " rename\n") { - c.Fatalf("Missing 'rename' log event\n%s", out) - } + c.Assert(out, checker.Contains, " rename\n", check.Commentf("Missing 'rename' log event\n")) } func (s *DockerSuite) TestEventsTop(c *check.C) { @@ -709,15 +605,13 @@ func (s *DockerSuite) TestEventsTop(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cID := strings.TrimSpace(out) - c.Assert(waitRun(cID), check.IsNil) + c.Assert(waitRun(cID), checker.IsNil) dockerCmd(c, "top", cID) dockerCmd(c, "stop", cID) out, _ = dockerCmd(c, "events", "--since=0", "-f", "container="+cID, "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, " top\n") { - c.Fatalf("Missing 'top' log event\n%s", out) - } + c.Assert(out, checker.Contains, " top\n", check.Commentf("Missing 'top' log event")) } // #13753 @@ -725,7 +619,7 @@ func (s *DockerSuite) TestEventsDefaultEmpty(c *check.C) { testRequires(c, DaemonIsLinux) dockerCmd(c, "run", "busybox") out, _ := dockerCmd(c, "events", fmt.Sprintf("--until=%d", daemonTime(c).Unix())) - c.Assert(strings.TrimSpace(out), check.Equals, "") + c.Assert(strings.TrimSpace(out), checker.Equals, "") } // #14316 @@ -737,14 +631,12 @@ func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *check.C) { out, _ := dockerCmd(c, "run", "-d", "busybox", "top") cID := strings.TrimSpace(out) - c.Assert(waitRun(cID), check.IsNil) + c.Assert(waitRun(cID), checker.IsNil) dockerCmd(c, "commit", cID, repoName) dockerCmd(c, "stop", cID) dockerCmd(c, "push", repoName) out, _ = dockerCmd(c, "events", "--since=0", "-f", "image="+repoName, "-f", "event=push", "--until="+strconv.Itoa(int(since))) - if !strings.Contains(out, repoName+": push\n") { - c.Fatalf("Missing 'push' log event for image %s\n%s", repoName, out) - } + c.Assert(out, checker.Contains, repoName+": push\n", check.Commentf("Missing 'push' log event")) }