@@ -2,7 +2,6 @@ package internal
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
5
"time"
7
6
8
7
"github.com/onsi/gomega/types"
@@ -53,42 +52,38 @@ func (g *Gomega) ExpectWithOffset(offset int, actual interface{}, extra ...inter
53
52
return NewAssertion (actual , g , offset , extra ... )
54
53
}
55
54
56
- func (g * Gomega ) Eventually (args ... interface {}) types.AsyncAssertion {
57
- return g .makeAsyncAssertion (AsyncAssertionTypeEventually , 0 , args ... )
55
+ func (g * Gomega ) Eventually (actualOrCtx interface {}, args ... interface {}) types.AsyncAssertion {
56
+ return g .makeAsyncAssertion (AsyncAssertionTypeEventually , 0 , actualOrCtx , args ... )
58
57
}
59
58
60
- func (g * Gomega ) EventuallyWithOffset (offset int , args ... interface {}) types.AsyncAssertion {
61
- return g .makeAsyncAssertion (AsyncAssertionTypeEventually , offset , args ... )
59
+ func (g * Gomega ) EventuallyWithOffset (offset int , actualOrCtx interface {}, args ... interface {}) types.AsyncAssertion {
60
+ return g .makeAsyncAssertion (AsyncAssertionTypeEventually , offset , actualOrCtx , args ... )
62
61
}
63
62
64
- func (g * Gomega ) Consistently (args ... interface {}) types.AsyncAssertion {
65
- return g .makeAsyncAssertion (AsyncAssertionTypeConsistently , 0 , args ... )
63
+ func (g * Gomega ) Consistently (actualOrCtx interface {}, args ... interface {}) types.AsyncAssertion {
64
+ return g .makeAsyncAssertion (AsyncAssertionTypeConsistently , 0 , actualOrCtx , args ... )
66
65
}
67
66
68
- func (g * Gomega ) ConsistentlyWithOffset (offset int , args ... interface {}) types.AsyncAssertion {
69
- return g .makeAsyncAssertion (AsyncAssertionTypeConsistently , offset , args ... )
67
+ func (g * Gomega ) ConsistentlyWithOffset (offset int , actualOrCtx interface {}, args ... interface {}) types.AsyncAssertion {
68
+ return g .makeAsyncAssertion (AsyncAssertionTypeConsistently , offset , actualOrCtx , args ... )
70
69
}
71
70
72
- func (g * Gomega ) makeAsyncAssertion (asyncAssertionType AsyncAssertionType , offset int , args ... interface {}) types.AsyncAssertion {
71
+ func (g * Gomega ) makeAsyncAssertion (asyncAssertionType AsyncAssertionType , offset int , actualOrCtx interface {}, args ... interface {}) types.AsyncAssertion {
73
72
baseOffset := 3
74
73
timeoutInterval := - time .Duration (1 )
75
74
pollingInterval := - time .Duration (1 )
76
75
intervals := []interface {}{}
77
76
var ctx context.Context
78
- if len (args ) == 0 {
79
- g .Fail (fmt .Sprintf ("Call to %s is missing a value or function to poll" , asyncAssertionType ), offset + baseOffset )
80
- return nil
81
- }
82
77
83
- actual := args [ 0 ]
84
- startingIndex := 1
85
- if _ , isCtx := args [ 0 ] .(context.Context ); isCtx && len (args ) > 1 {
78
+ actual := actualOrCtx
79
+ startingIndex := 0
80
+ if _ , isCtx := actualOrCtx .(context.Context ); isCtx && len (args ) > 0 {
86
81
// the first argument is a context, we should accept it as the context _only if_ it is **not** the only argumnent **and** the second argument is not a parseable duration
87
82
// this is due to an unfortunate ambiguity in early version of Gomega in which multi-type durations are allowed after the actual
88
- if _ , err := toDuration (args [1 ]); err != nil {
89
- ctx = args [ 0 ] .(context.Context )
90
- actual = args [1 ]
91
- startingIndex = 2
83
+ if _ , err := toDuration (args [0 ]); err != nil {
84
+ ctx = actualOrCtx .(context.Context )
85
+ actual = args [0 ]
86
+ startingIndex = 1
92
87
}
93
88
}
94
89
0 commit comments