github.com/onsi/gomega@v1.32.0/types/types.go (about) 1 package types 2 3 import ( 4 "context" 5 "time" 6 ) 7 8 type GomegaFailHandler func(message string, callerSkip ...int) 9 10 // A simple *testing.T interface wrapper 11 type GomegaTestingT interface { 12 Helper() 13 Fatalf(format string, args ...interface{}) 14 } 15 16 // Gomega represents an object that can perform synchronous and assynchronous assertions with Gomega matchers 17 type Gomega interface { 18 Ω(actual interface{}, extra ...interface{}) Assertion 19 Expect(actual interface{}, extra ...interface{}) Assertion 20 ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) Assertion 21 22 Eventually(actualOrCtx interface{}, args ...interface{}) AsyncAssertion 23 EventuallyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion 24 25 Consistently(actualOrCtx interface{}, args ...interface{}) AsyncAssertion 26 ConsistentlyWithOffset(offset int, actualOrCtx interface{}, args ...interface{}) AsyncAssertion 27 28 SetDefaultEventuallyTimeout(time.Duration) 29 SetDefaultEventuallyPollingInterval(time.Duration) 30 SetDefaultConsistentlyDuration(time.Duration) 31 SetDefaultConsistentlyPollingInterval(time.Duration) 32 } 33 34 // All Gomega matchers must implement the GomegaMatcher interface 35 // 36 // For details on writing custom matchers, check out: http://onsi.github.io/gomega/#adding-your-own-matchers 37 type GomegaMatcher interface { 38 Match(actual interface{}) (success bool, err error) 39 FailureMessage(actual interface{}) (message string) 40 NegatedFailureMessage(actual interface{}) (message string) 41 } 42 43 /* 44 GomegaMatchers that also match the OracleMatcher interface can convey information about 45 whether or not their result will change upon future attempts. 46 47 This allows `Eventually` and `Consistently` to short circuit if success becomes impossible. 48 49 For example, a process' exit code can never change. So, gexec's Exit matcher returns `true` 50 for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore. 51 */ 52 type OracleMatcher interface { 53 MatchMayChangeInTheFuture(actual interface{}) bool 54 } 55 56 func MatchMayChangeInTheFuture(matcher GomegaMatcher, value interface{}) bool { 57 oracleMatcher, ok := matcher.(OracleMatcher) 58 if !ok { 59 return true 60 } 61 62 return oracleMatcher.MatchMayChangeInTheFuture(value) 63 } 64 65 // AsyncAssertions are returned by Eventually and Consistently and enable matchers to be polled repeatedly to ensure 66 // they are eventually satisfied 67 type AsyncAssertion interface { 68 Should(matcher GomegaMatcher, optionalDescription ...interface{}) bool 69 ShouldNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool 70 71 WithOffset(offset int) AsyncAssertion 72 WithTimeout(interval time.Duration) AsyncAssertion 73 WithPolling(interval time.Duration) AsyncAssertion 74 Within(timeout time.Duration) AsyncAssertion 75 ProbeEvery(interval time.Duration) AsyncAssertion 76 WithContext(ctx context.Context) AsyncAssertion 77 WithArguments(argsToForward ...interface{}) AsyncAssertion 78 MustPassRepeatedly(count int) AsyncAssertion 79 } 80 81 // Assertions are returned by Ω and Expect and enable assertions against Gomega matchers 82 type Assertion interface { 83 Should(matcher GomegaMatcher, optionalDescription ...interface{}) bool 84 ShouldNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool 85 86 To(matcher GomegaMatcher, optionalDescription ...interface{}) bool 87 ToNot(matcher GomegaMatcher, optionalDescription ...interface{}) bool 88 NotTo(matcher GomegaMatcher, optionalDescription ...interface{}) bool 89 90 WithOffset(offset int) Assertion 91 92 Error() Assertion 93 }