github.com/operator-framework/operator-lifecycle-manager@v0.30.0/test/e2e/dsl/dsl.go (about)

     1  package dsl
     2  
     3  import (
     4  	"fmt"
     5  
     6  	g "github.com/onsi/ginkgo/v2"
     7  )
     8  
     9  // IgnoreError acknowledges that an error value is being intentionally
    10  // disregarded.
    11  //
    12  // In general, errors should not be ignored, however, errors may be
    13  // unimportant in certain test scenarios. IgnoreError accepts a
    14  // variable-length argument list, like Expect(), as a convenience for
    15  // functions returning values and an error, e.g. `func DoSomething()
    16  // (string, error)`. IgnoreError will fail the current test if the
    17  // last argument is neither nil nor a non-nil error.
    18  func IgnoreError(vals ...interface{}) {
    19  	if len(vals) == 0 {
    20  		return
    21  	}
    22  	err := vals[len(vals)-1]
    23  	if err == nil {
    24  		return
    25  	}
    26  	if _, ok := err.(error); ok {
    27  		return
    28  	}
    29  	g.Fail(fmt.Sprintf("the last argument to IgnoreError must be an error, but it was %T", err))
    30  }