Skip to content

Commit

Permalink
Merge pull request #3322 from sklarsa/steve/unit-tests
Browse files Browse the repository at this point in the history
馃尡  Adds version command E2E test to improve coverage
  • Loading branch information
k8s-ci-robot committed Apr 14, 2023
2 parents eb8b341 + d60ebab commit b868893
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 b868893

Please sign in to comment.