mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-10 08:20:23 +00:00
00b94da38a
Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.23.0 to 1.26.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.23.0...v1.26.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package matchers
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type formattedGomegaError interface {
|
|
FormattedGomegaError() string
|
|
}
|
|
|
|
type SucceedMatcher struct {
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) {
|
|
// is purely nil?
|
|
if actual == nil {
|
|
return true, nil
|
|
}
|
|
|
|
// must be an 'error' type
|
|
if !isError(actual) {
|
|
return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
|
|
}
|
|
|
|
// must be nil (or a pointer to a nil)
|
|
return isNil(actual), nil
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
|
|
var fgErr formattedGomegaError
|
|
if errors.As(actual.(error), &fgErr) {
|
|
return fgErr.FormattedGomegaError()
|
|
}
|
|
return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
|
return "Expected failure, but got no error."
|
|
}
|