Skip to content

Commit

Permalink
fix(ci) kumactl test output matching (#2446)
Browse files Browse the repository at this point in the history
This test failure is a result of the combination of #2419 and #2438.

The fix is to test for error output using a substring match, which was
already done in most places in #2438, but this instance was overlooked.

Signed-off-by: James Peach <james.peach@konghq.com>
  • Loading branch information
jpeach authored Jul 29, 2021
1 parent 755ccf8 commit 10d4926
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/kumactl/cmd/config/config_control_planes_switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"strings"
"unicode"

"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

"github.com/spf13/cobra"

"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl config control-planes use", func() {
Expand All @@ -39,14 +39,13 @@ var _ = Describe("kumactl config control-planes use", func() {
rootCmd = test.DefaultTestingRootCmd()

// Different versions of cobra might emit errors to stdout
// or stderr. It's too fragile to depend on precidely what
// or stderr. It's too fragile to depend on precisely what
// it does, and that's not something that needs to be tested
// within Kuma anyway. So we just combine all the output
// and validate the aggregate.
outbuf = &bytes.Buffer{}
rootCmd.SetOut(outbuf)
rootCmd.SetErr(outbuf)

})

Describe("error cases", func() {
Expand All @@ -60,8 +59,7 @@ var _ = Describe("kumactl config control-planes use", func() {
// then
Expect(err.Error()).To(MatchRegexp(requiredFlagNotSet("name")))
// and
Expect(outbuf.String()).To(Equal(`Error: required flag(s) "name" not set
`))
Expect(outbuf.String()).To(ContainSubstring(`Error: required flag(s) "name" not set`))
})

It("should fail to switch to unknown Control Plane", func() {
Expand All @@ -74,8 +72,7 @@ var _ = Describe("kumactl config control-planes use", func() {
// then
Expect(err).To(MatchError(`there is no Control Plane with name "example"`))
// and
Expect(outbuf.String()).To(Equal(`Error: there is no Control Plane with name "example"
`))
Expect(outbuf.String()).To(ContainSubstring(`Error: there is no Control Plane with name "example"`))
})
})

Expand Down

0 comments on commit 10d4926

Please sign in to comment.