Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/volume_ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var _ = Describe("Podman volume ls", func() {
empty := podmanTest.PodmanExitCleanly("volume", "ls")
Expect(empty.OutputToString()).To(ContainSubstring("DRIVER"))
Expect(empty.OutputToString()).To(ContainSubstring("VOLUME NAME"))
Expect(empty.ErrorToStringArray()).To(HaveLen(1))
Expect(empty.ErrorToStringArray()).To(BeEmpty())

session := podmanTest.Podman([]string{"volume", "create", "myvol"})
session.WaitWithDefaultTimeout()
Expand Down
8 changes: 7 additions & 1 deletion test/utils/podmansession_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ var _ = Describe("PodmanSession test", func() {
})

It("Test ErrorToStringArray", func() {
Expect(session.ErrorToStringArray()).To(Equal([]string{"PodmanSession", "test", "Podman Session", ""}))
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 GrepString", func() {
Expand Down
8 changes: 7 additions & 1 deletion test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,14 @@ func (s *PodmanSession) ErrorToString() string {
// ErrorToStringArray returns the stderr output as a []string
// where each array item is a line split by newline
func (s *PodmanSession) ErrorToStringArray() []string {
var results []string
output := string(s.Err.Contents())
return strings.Split(output, "\n")
for line := range strings.SplitSeq(output, "\n") {
if line != "" {
results = append(results, line)
}
}
return results
}

// GrepString takes session output and behaves like grep. it returns a bool
Expand Down
Loading