spiegel_podman/test/utils/podmansession_test.go
Tushar Verma d153f4750b test/e2e: remove IsJSONOutputValid
Asserting a bool against an expected bool says nothing about the output
when it fails. BeValidJSON() prints it, and now that the matcher handles
a non match properly the negative rows in the info and version table
tests can use it too.

Part of #18540.

Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
2026-08-26 22:51:51 +05:30

55 lines
1.7 KiB
Go

package utils_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "go.podman.io/podman/v6/test/utils"
)
var _ = Describe("PodmanSession test", func() {
var session *PodmanSession
BeforeEach(func() {
session = StartFakeCmdSession([]string{"PodmanSession", "test", "Podman Session"})
session.WaitWithDefaultTimeout()
})
It("Test OutputToString", func() {
Expect(session.OutputToString()).To(Equal("PodmanSession test Podman Session"))
})
It("Test OutputToStringArray", func() {
Expect(session.OutputToStringArray()).To(Equal([]string{"PodmanSession", "test", "Podman Session"}))
})
It("Test ErrorToString", func() {
Expect(session.ErrorToString()).To(Equal("PodmanSession test Podman Session"))
})
It("Test ErrorToStringArray", func() {
Expect(session.ErrorToStringArray()).To(Equal([]string{"PodmanSession", "test", "Podman Session"}))
})
It("Test ErrorToStringArray with empty output", func() {
session = StartFakeCmdSession([]string{})
session.WaitWithDefaultTimeout()
Expect(session.ErrorToStringArray()).To(BeEmpty())
})
It("Test BeValidJSON", func() {
session = StartFakeCmdSession([]string{`{"page":1,"fruits":["apple","peach","pear"]}`})
session.WaitWithDefaultTimeout()
Expect(session.OutputToString()).To(BeValidJSON())
session = StartFakeCmdSession([]string{"I am not JSON"})
session.WaitWithDefaultTimeout()
Expect(session.OutputToString()).ToNot(BeValidJSON())
})
It("Test WaitWithDefaultTimeout", func() {
session = StartFakeCmdSession([]string{"sleep", "2"})
Expect(session.ExitCode()).Should(Equal(-1))
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).Should(Equal(0))
})
})