Skip to content

Commit 2a7202b

Browse files
author
Kenichi Omichi
committed
Use framework.ExpectNoError() for e2e/
The e2e test framework has ExpectNoError() for readable test code. This replaces Expect(err).NotTo(HaveOccurred()) with it.
1 parent 22b6c69 commit 2a7202b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/e2e/examples.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"k8s.io/kubernetes/test/e2e/framework/testfiles"
3535

3636
. "github.com/onsi/ginkgo"
37-
. "github.com/onsi/gomega"
3837
)
3938

4039
const (
@@ -77,7 +76,7 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
7776
passed := true
7877
checkRestart := func(podName string, timeout time.Duration) {
7978
err := framework.WaitForPodNameRunningInNamespace(c, podName, ns)
80-
Expect(err).NotTo(HaveOccurred())
79+
framework.ExpectNoError(err)
8180
for t := time.Now(); time.Since(t) < timeout; time.Sleep(framework.Poll) {
8281
pod, err := c.CoreV1().Pods(ns).Get(podName, metav1.GetOptions{})
8382
framework.ExpectNoError(err, fmt.Sprintf("getting pod %s", podName))
@@ -123,11 +122,11 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
123122
framework.RunKubectlOrDieInput(secretYaml, "create", "-f", "-", nsFlag)
124123
framework.RunKubectlOrDieInput(podYaml, "create", "-f", "-", nsFlag)
125124
err := framework.WaitForPodNoLongerRunningInNamespace(c, podName, ns)
126-
Expect(err).NotTo(HaveOccurred())
125+
framework.ExpectNoError(err)
127126

128127
By("checking if secret was read correctly")
129128
_, err = framework.LookForStringInLog(ns, "secret-test-pod", "test-container", "value-1", serverStartTimeout)
130-
Expect(err).NotTo(HaveOccurred())
129+
framework.ExpectNoError(err)
131130
})
132131
})
133132

@@ -141,13 +140,13 @@ var _ = framework.KubeDescribe("[Feature:Example]", func() {
141140
By("creating the pod")
142141
framework.RunKubectlOrDieInput(podYaml, "create", "-f", "-", nsFlag)
143142
err := framework.WaitForPodNoLongerRunningInNamespace(c, podName, ns)
144-
Expect(err).NotTo(HaveOccurred())
143+
framework.ExpectNoError(err)
145144

146145
By("checking if name and namespace were passed correctly")
147146
_, err = framework.LookForStringInLog(ns, podName, "test-container", fmt.Sprintf("MY_POD_NAMESPACE=%v", ns), serverStartTimeout)
148-
Expect(err).NotTo(HaveOccurred())
147+
framework.ExpectNoError(err)
149148
_, err = framework.LookForStringInLog(ns, podName, "test-container", fmt.Sprintf("MY_POD_NAME=%v", podName), serverStartTimeout)
150-
Expect(err).NotTo(HaveOccurred())
149+
framework.ExpectNoError(err)
151150
})
152151
})
153152
})

0 commit comments

Comments
 (0)