summaryrefslogtreecommitdiff
path: root/vendor/github.com/onsi/gomega/gstruct/ignore.go
blob: 4396573e440e5706149cde081222567ee58e7f9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// untested sections: 2

package gstruct

import (
	"github.com/onsi/gomega/types"
)

//Ignore ignores the actual value and always succeeds.
//  Expect(nil).To(Ignore())
//  Expect(true).To(Ignore())
func Ignore() types.GomegaMatcher {
	return &IgnoreMatcher{true}
}

//Reject ignores the actual value and always fails. It can be used in conjunction with IgnoreMissing
//to catch problematic elements, or to verify tests are running.
//  Expect(nil).NotTo(Reject())
//  Expect(true).NotTo(Reject())
func Reject() types.GomegaMatcher {
	return &IgnoreMatcher{false}
}

// A matcher that either always succeeds or always fails.
type IgnoreMatcher struct {
	Succeed bool
}

func (m *IgnoreMatcher) Match(actual interface{}) (bool, error) {
	return m.Succeed, nil
}

func (m *IgnoreMatcher) FailureMessage(_ interface{}) (message string) {
	return "Unconditional failure"
}

func (m *IgnoreMatcher) NegatedFailureMessage(_ interface{}) (message string) {
	return "Unconditional success"
}