Skip to content

Commit b27fe7f

Browse files
authored
Merge pull request kubernetes#74314 from oomichi/add-ExpectError
Add ExpectError() to e2e test framework
2 parents e45f92f + 4365444 commit b27fe7f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

test/e2e/framework/util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,11 @@ func RandomSuffix() string {
20392039
return strconv.Itoa(r.Int() % 10000)
20402040
}
20412041

2042+
// ExpectError expects an error happens, otherwise an exception raises
2043+
func ExpectError(err error, explain ...interface{}) {
2044+
gomega.Expect(err).To(gomega.HaveOccurred(), explain...)
2045+
}
2046+
20422047
// ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
20432048
func ExpectNoError(err error, explain ...interface{}) {
20442049
ExpectNoErrorWithOffset(1, err, explain...)

test/e2e/storage/testsuites/provisioning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ func (t StorageClassTest) TestBindingWaitForFirstConsumerMultiPVC(claims []*v1.P
483483
// Wait for ClaimProvisionTimeout (across all PVCs in parallel) and make sure the phase did not become Bound i.e. the Wait errors out
484484
By("checking the claims are in pending state")
485485
err = framework.WaitForPersistentVolumeClaimsPhase(v1.ClaimBound, t.Client, namespace, claimNames, 2*time.Second /* Poll */, framework.ClaimProvisionShortTimeout, true)
486-
Expect(err).To(HaveOccurred())
486+
framework.ExpectError(err)
487487
verifyPVCsPending(t.Client, createdClaims)
488488

489489
By("creating a pod referring to the claims")

0 commit comments

Comments
 (0)