1
0
Fork 0
mirror of https://github.com/Luzifer/duplicity-backup.git synced 2024-11-14 01:42:52 +00:00
duplicity-backup/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go

30 lines
809 B
Go
Raw Normal View History

2016-05-22 13:04:37 +00:00
package matchers
import (
"fmt"
"github.com/onsi/gomega/format"
)
type HaveOccurredMatcher struct {
}
func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) {
if isNil(actual) {
return false, nil
}
if isError(actual) {
return true, nil
}
return false, fmt.Errorf("Expected an error. Got:\n%s", format.Object(actual, 1))
}
func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected an error to have occurred. Got:\n%s", format.Object(actual, 1))
}
func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return fmt.Sprintf("Expected error:\n%s\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1), "not to have occurred")
}