Skip to content

Commit

Permalink
adds small version cmd test
Browse files Browse the repository at this point in the history
  • Loading branch information
sklarsa committed Apr 10, 2023
1 parent 1ab1f16 commit e9f1f0c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,25 @@ plugins:
)
Expect(err).NotTo(HaveOccurred())
Expect(hasSubCommand(c.cmd, "version")).To(BeTrue())

// Test the version command
c.cmd.SetArgs([]string{"version"})
// Overwrite stdout to read the output and reset it afterwards
r, w, _ := os.Pipe()
temp := os.Stdout
defer func() {
os.Stdout = temp
}()
os.Stdout = w
Expect(c.cmd.Execute()).Should(Succeed())

_ = w.Close()

Expect(err).NotTo(HaveOccurred())
printed, _ := io.ReadAll(r)
Expect(string(printed)).To(Equal(
fmt.Sprintf("%s\n", version)))

})
})

Expand Down

0 comments on commit e9f1f0c

Please sign in to comment.