initial commit
[govpp.git] / vendor / github.com / onsi / gomega / matchers / succeed_matcher.go
1 package matchers
2
3 import (
4         "fmt"
5
6         "github.com/onsi/gomega/format"
7 )
8
9 type SucceedMatcher struct {
10 }
11
12 func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) {
13         // is purely nil?
14         if actual == nil {
15                 return true, 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 nil (or a pointer to a nil)
24         return isNil(actual), nil
25 }
26
27 func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
28         return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
29 }
30
31 func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
32         return "Expected failure, but got no error."
33 }