Skip to content

Commit

Permalink
test: Ginkgo and Gomega update
Browse files Browse the repository at this point in the history
The new Gomega version supports testing a function with no return
value (onsi/gomega#198 (comment)). This
makes it possible to simplify the metrics test.
  • Loading branch information
pohly committed Jun 10, 2021
1 parent cf76839 commit ff66684
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -14,7 +14,7 @@ require (
github.com/kubernetes-csi/csi-test/v4 v4.2.0
github.com/miekg/dns v1.1.38 // indirect
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d
github.com/operator-framework/operator-lib v0.4.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_model v0.2.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Expand Up @@ -522,6 +522,8 @@ github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
github.com/onsi/gomega v1.10.4/go.mod h1:g/HbgYopi++010VEqkFgJHKC09uJiW9UkXvMUuKHUCQ=
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d h1:xP4paM8h3wbI0mhcjOZeeRNI2HzqxIgKSMJv+brTHaE=
github.com/onsi/gomega v1.13.1-0.20210610024953-2f04e6e3467d/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
Expand Down
11 changes: 1 addition & 10 deletions test/e2e/metrics/metrics.go
Expand Up @@ -78,13 +78,6 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
pod.Namespace, pod.Name, port.ContainerPort)
resp, err := client.Get(url)
framework.ExpectNoError(err, "GET failed")
// When wrapped with InterceptGomegaFailures, err == nil doesn't
// cause the function to abort. We have to do that ourselves before
// using resp to avoid a panic.
// https://github.com/onsi/gomega/issues/198#issuecomment-856630787
if err != nil {
return
}
data, err := ioutil.ReadAll(resp.Body)
framework.ExpectNoError(err, "read GET response")
name := pod.Name + "/" + container.Name
Expand All @@ -109,9 +102,7 @@ var _ = deploy.Describe("direct-testing", "direct-testing-metrics", "", func(d *
}
Expect(numPods).NotTo(Equal(0), "at least one container should have a 'metrics' port")
}
Eventually(func() string {
return strings.Join(InterceptGomegaFailures(test), "\n")
}, "10s", "1s").Should(BeEmpty())
Eventually(test, "10s", "1s").Should(Succeed())
})

It("rejects large headers", func() {
Expand Down

0 comments on commit ff66684

Please sign in to comment.