Skip to content

Commit 41ffa42

Browse files
AxeZhank8s-publishing-bot
authored andcommitted
remove dead code in test
Kubernetes-commit: 220d5c2e5439fb210c74264353534c7e9167c543
1 parent abbf317 commit 41ffa42

File tree

1 file changed

+27
-35
lines changed

1 file changed

+27
-35
lines changed

pkg/util/wait/loop_test.go

+27-35
Original file line numberDiff line numberDiff line change
@@ -206,42 +206,34 @@ func Test_loopConditionUntilContext_semantic(t *testing.T) {
206206
}
207207

208208
for _, test := range tests {
209-
for _, immediate := range []bool{true, false} {
210-
t.Run(fmt.Sprintf("immediate=%t", immediate), func(t *testing.T) {
211-
for _, sliding := range []bool{true, false} {
212-
t.Run(fmt.Sprintf("sliding=%t", sliding), func(t *testing.T) {
213-
t.Run(test.name, func(t *testing.T) {
214-
contextFn := test.context
215-
if contextFn == nil {
216-
contextFn = defaultContext
217-
}
218-
ctx, cancel := contextFn()
219-
defer cancel()
220-
221-
timer := Backoff{Duration: time.Microsecond}.Timer()
222-
attempts := 0
223-
err := loopConditionUntilContext(ctx, timer, test.immediate, test.sliding, func(_ context.Context) (bool, error) {
224-
attempts++
225-
defer func() {
226-
if test.cancelContextAfter > 0 && test.cancelContextAfter == attempts {
227-
cancel()
228-
}
229-
}()
230-
return test.callback(attempts)
231-
})
232-
233-
if test.errExpected != err {
234-
t.Errorf("expected error: %v but got: %v", test.errExpected, err)
235-
}
236-
237-
if test.attemptsExpected != attempts {
238-
t.Errorf("expected attempts count: %d but got: %d", test.attemptsExpected, attempts)
239-
}
240-
})
241-
})
242-
}
209+
t.Run(test.name, func(t *testing.T) {
210+
contextFn := test.context
211+
if contextFn == nil {
212+
contextFn = defaultContext
213+
}
214+
ctx, cancel := contextFn()
215+
defer cancel()
216+
217+
timer := Backoff{Duration: time.Microsecond}.Timer()
218+
attempts := 0
219+
err := loopConditionUntilContext(ctx, timer, test.immediate, test.sliding, func(_ context.Context) (bool, error) {
220+
attempts++
221+
defer func() {
222+
if test.cancelContextAfter > 0 && test.cancelContextAfter == attempts {
223+
cancel()
224+
}
225+
}()
226+
return test.callback(attempts)
243227
})
244-
}
228+
229+
if test.errExpected != err {
230+
t.Errorf("expected error: %v but got: %v", test.errExpected, err)
231+
}
232+
233+
if test.attemptsExpected != attempts {
234+
t.Errorf("expected attempts count: %d but got: %d", test.attemptsExpected, attempts)
235+
}
236+
})
245237
}
246238
}
247239

0 commit comments

Comments
 (0)