initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / have_occurred_matcher.go
1 package matchers
2
3 import (
4         "fmt"
5
6         "github.com/onsi/gomega/format"
7 )
8
9 type HaveOccurredMatcher struct {
10 }
11
12 func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) {
13         // is purely nil?
14         if actual == nil {
15                 return false, nil
16         }
17
18         // must be an 'error' type
19         if !isError(actual) {
20                 return false, fmt.Errorf("Expected an error-type.  Got:\n%s", format.Object(actual, 1))
21         }
22
23         // must be non-nil (or a pointer to a non-nil)
24         return !isNil(actual), nil
25 }
26
27 func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message string) {
28         return fmt.Sprintf("Expected an error to have occurred.  Got:\n%s", format.Object(actual, 1))
29 }
30
31 func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) {
32         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")
33 }