MCPcopy
hub / github.com/moby/moby / TestEventsFormat

Method TestEventsFormat

integration-cli/docker_cli_events_test.go:716–737  ·  view source on GitHub ↗
(c *testing.T)

Source from the content-addressed store, hash-verified

714}
715
716func (s *DockerCLIEventSuite) TestEventsFormat(c *testing.T) {
717 since := daemonUnixTime(c)
718 cli.DockerCmd(c, "run", "--rm", "busybox", "true")
719 cli.DockerCmd(c, "run", "--rm", "busybox", "true")
720 out := cli.DockerCmd(c, "events", "--since", since, "--until", daemonUnixTime(c), "--format", "{{json .}}").Stdout()
721 dec := json.NewDecoder(strings.NewReader(out))
722 // make sure we got 2 start events
723 startCount := 0
724 for {
725 var err error
726 var ev eventtypes.Message
727 if err = dec.Decode(&ev); err == io.EOF {
728 break
729 }
730 assert.NilError(c, err)
731 if ev.Action == eventtypes.ActionStart {
732 startCount++
733 }
734 }
735
736 assert.Equal(c, startCount, 2, "should have had 2 start events but had %d, out: %s", startCount, out)
737}
738
739func (s *DockerCLIEventSuite) TestEventsFormatBadFunc(c *testing.T) {
740 // make sure it fails immediately, without receiving any event

Callers

nothing calls this directly

Calls 5

DecodeMethod · 0.95
DockerCmdFunction · 0.92
daemonUnixTimeFunction · 0.85
EqualMethod · 0.80
StdoutMethod · 0.45

Tested by

no test coverage detected