Merge pull request #127558 from pohly/e2e-framework-docs

e2e framework: better documentation of ExpectNoError
This commit is contained in:
Kubernetes Prow Robot 2024-09-23 14:12:00 +01:00 committed by GitHub
commit f187480140
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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