mirror of
https://github.com/containers/podman.git
synced 2025-12-03 19:59:39 +08:00
* Make sure that all vendored dependencies are in sync with the code and the vendor.conf by running `make vendor` with a follow-up status check of the git tree. * Vendor ginkgo and gomega to include the test dependencies. Signed-off-by: Chris Evic <cevich@redhat.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
34 lines
834 B
Go
34 lines
834 B
Go
package matchers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
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) {
|
|
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."
|
|
}
|