mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 10:43:56 +00:00
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))
This commit is contained in:
parent
e456fbfaa6
commit
e5aa609513
@ -294,12 +294,22 @@ func (f *FailureError) backtrace() {
|
|||||||
var ErrFailure error = FailureError{}
|
var ErrFailure error = FailureError{}
|
||||||
|
|
||||||
// ExpectNoError checks if "err" is set, and if so, fails assertion while logging the error.
|
// 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{}) {
|
func ExpectNoError(err error, explain ...interface{}) {
|
||||||
ExpectNoErrorWithOffset(1, err, explain...)
|
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
|
// 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").
|
// (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{}) {
|
func ExpectNoErrorWithOffset(offset int, err error, explain ...interface{}) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user