From e5aa609513d9576dda824fe9b54c2c1bb07cd05b Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 23 Sep 2024 10:58:06 +0200 Subject: [PATCH] e2e framework: better documentation of ExpectNoError It wasn't clear from the comments what "explain" does, leading to calls like this: framework.ExpectNoError(fmt.Errorf("additional info ....: %v", ..., err)) --- test/e2e/framework/expect.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/e2e/framework/expect.go b/test/e2e/framework/expect.go index 9d7c6474557..a4e2446accb 100644 --- a/test/e2e/framework/expect.go +++ b/test/e2e/framework/expect.go @@ -294,12 +294,22 @@ func (f *FailureError) backtrace() { var ErrFailure error = FailureError{} // ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error. +// +// As in [gomega.Expect], the explain parameters can be used to provide +// additional information in case of a failure in one of these two ways: +// - A single string is used as first line of the failure message directly. +// - A string with additional parameters is passed through [fmt.Sprintf]. func ExpectNoError(err error, explain ...interface{}) { ExpectNoErrorWithOffset(1, err, explain...) } // ExpectNoErrorWithOffset checks if "err" is set, and if so, fails assertion while logging the error at "offset" levels above its caller // (for example, for call chain f -> g -> ExpectNoErrorWithOffset(1, ...) error would be logged for "f"). +// +// As in [gomega.Expect], the explain parameters can be used to provide +// additional information in case of a failure in one of these two ways: +// - A single string is used as first line of the failure message directly. +// - A string with additional parameters is passed through [fmt.Sprintf]. func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) { if err == nil { return