github.com/onsi/gomega@v1.32.0/gstruct/ignore.go (about) 1 // untested sections: 2 2 3 package gstruct 4 5 import ( 6 "github.com/onsi/gomega/types" 7 ) 8 9 //Ignore ignores the actual value and always succeeds. 10 // Expect(nil).To(Ignore()) 11 // Expect(true).To(Ignore()) 12 func Ignore() types.GomegaMatcher { 13 return &IgnoreMatcher{true} 14 } 15 16 //Reject ignores the actual value and always fails. It can be used in conjunction with IgnoreMissing 17 //to catch problematic elements, or to verify tests are running. 18 // Expect(nil).NotTo(Reject()) 19 // Expect(true).NotTo(Reject()) 20 func Reject() types.GomegaMatcher { 21 return &IgnoreMatcher{false} 22 } 23 24 // A matcher that either always succeeds or always fails. 25 type IgnoreMatcher struct { 26 Succeed bool 27 } 28 29 func (m *IgnoreMatcher) Match(actual interface{}) (bool, error) { 30 return m.Succeed, nil 31 } 32 33 func (m *IgnoreMatcher) FailureMessage(_ interface{}) (message string) { 34 return "Unconditional failure" 35 } 36 37 func (m *IgnoreMatcher) NegatedFailureMessage(_ interface{}) (message string) { 38 return "Unconditional success" 39 }