ignore.go 960 B

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