ignore.go 985 B

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