Skip to content

Commit 728129a

Browse files
committed
test(wait): use RunAndReturn for dynamic mock in MultipleChecks test
Replace Return(func...) with RunAndReturn(func...) in TestExecStrategyWaitUntilReady_MultipleChecks. With Return, the function is returned as the value rather than being invoked on each call. RunAndReturn ensures the mock executes the function dynamically, which is the correct pattern for time-dependent behavior. Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
1 parent dcc5bea commit 728129a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

wait/exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestExecStrategyWaitUntilReadyForExec(t *testing.T) {
6666
func TestExecStrategyWaitUntilReady_MultipleChecks(t *testing.T) {
6767
successAfter := time.Now().Add(2 * time.Second)
6868
target := newMockStrategyTarget(t)
69-
target.On("Exec", mock.Anything, mock.Anything, mock.Anything).Return(
69+
target.On("Exec", mock.Anything, mock.Anything, mock.Anything).RunAndReturn(
7070
func(ctx context.Context, cmd []string, opts ...tcexec.ProcessOption) (int, io.Reader, error) {
7171
if time.Now().After(successAfter) {
7272
return 0, nil, nil

0 commit comments

Comments
 (0)