Skip to content

Commit

Permalink
fix(kumactl) use strings for stderr output test check (#2323)
Browse files Browse the repository at this point in the history
If we assert that kumactl standard error is empty using a byte buffer,
then the Ginkgo error shows a hex dump, which isn't that easy to read.
Switch to checking for an empty standard error string so that Ginkgo
shows any error messages directly in the test failure.

Signed-off-by: James Peach <james.peach@konghq.com>
  • Loading branch information
jpeach authored Jul 8, 2021
1 parent 91e9477 commit 06274a4
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/kumactl/cmd/completion/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ = Describe("kumactl completion", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_control_plane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var _ = Describe("kumactl install control-plane", func() {

// then command succeed
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = Describe("kumactl install crds", func() {
// then
Expect(err).ToNot(HaveOccurred())
// and
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// when
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("kumactl install demo", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("kumactl install gateway", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("kumactl install logging", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var _ = Describe("kumactl install metrics", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var _ = Describe("kumactl install tracing", func() {

// then
Expect(err).ToNot(HaveOccurred())
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// and output matches golden files
actual := stdout.Bytes()
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_transparent_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("kumactl install tracing", func() {
// then
Expect(err).ToNot(HaveOccurred())
// and
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// when
regex, err := ioutil.ReadFile(filepath.Join("testdata", given.goldenFile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = Describe("kumactl install tracing", func() {
// then
Expect(err).ToNot(HaveOccurred())
// and
Expect(stderr.Bytes()).To(BeNil())
Expect(stderr.String()).To(BeEmpty())

// when
regex, err := ioutil.ReadFile(filepath.Join("testdata", given.goldenFile))
Expand Down

0 comments on commit 06274a4

Please sign in to comment.