Skip to content

Commit

Permalink
Move events streaming test to own suite with BeforeEach and AfterEach
Browse files Browse the repository at this point in the history
  • Loading branch information
surik committed Aug 18, 2023
1 parent 5461a96 commit 163da8b
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions test/e2e/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,41 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
. "github.com/onsi/gomega/gexec"
)

// The actual test suite
var _ = t.Describe("events", func() {
var _ = t.Describe("events options validation", func() {
It("should fail with not supported output format", func() {
t.CrictlExpectFailure("events --output=ini", "", "don't support .* format")
})

It("should fail with template set for non go-template format", func() {
t.CrictlExpectFailure("events --template=\"{{ .containerID }}\"", "", "template can't be used with .* format")
t.CrictlExpectFailure("events --template={{.containerID}}", "", "template can't be used with .* format")
})

It("should fail with bad template set for go-template format", func() {
t.CrictlExpectFailure("events --output=go-template --template=\"{{\"", "", "failed to parse go-template")
t.CrictlExpectFailure("events --output=go-template --template={{", "", "failed to parse go-template")
})
})

It("should succeed", func() {
// Given
endpoint, testDir, crio := t.StartCrio()
// The actual test suite
var _ = t.Describe("events", func() {
var (
endpoint, testDir string
crio *Session
)
BeforeEach(func() {
endpoint, testDir, crio = t.StartCrio()
})

// When
session := t.CrictlWithEndpointNoWait(endpoint, "events")
Expect(session.Out).ToNot(Say("unknown method GetContainerEvents")) // no errors
AfterEach(func() {
t.StopCrio(testDir, crio)
})

// Then
It("should succeed", func() {
session := t.CrictlWithEndpointNoWait(endpoint, "events")
defer session.Terminate()
t.StopCrio(testDir, crio)
Expect(session.Out).ToNot(Say("unknown method GetContainerEvents")) // no errors
})
})

0 comments on commit 163da8b

Please sign in to comment.