mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-26 03:52:13 +00:00
remove dead code in test
This commit is contained in:
parent
79f9bfdc8e
commit
220d5c2e54
@ -206,42 +206,34 @@ func Test_loopConditionUntilContext_semantic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
for _, immediate := range []bool{true, false} {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
t.Run(fmt.Sprintf("immediate=%t", immediate), func(t *testing.T) {
|
contextFn := test.context
|
||||||
for _, sliding := range []bool{true, false} {
|
if contextFn == nil {
|
||||||
t.Run(fmt.Sprintf("sliding=%t", sliding), func(t *testing.T) {
|
contextFn = defaultContext
|
||||||
t.Run(test.name, func(t *testing.T) {
|
}
|
||||||
contextFn := test.context
|
ctx, cancel := contextFn()
|
||||||
if contextFn == nil {
|
defer cancel()
|
||||||
contextFn = defaultContext
|
|
||||||
}
|
|
||||||
ctx, cancel := contextFn()
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
timer := Backoff{Duration: time.Microsecond}.Timer()
|
timer := Backoff{Duration: time.Microsecond}.Timer()
|
||||||
attempts := 0
|
attempts := 0
|
||||||
err := loopConditionUntilContext(ctx, timer, test.immediate, test.sliding, func(_ context.Context) (bool, error) {
|
err := loopConditionUntilContext(ctx, timer, test.immediate, test.sliding, func(_ context.Context) (bool, error) {
|
||||||
attempts++
|
attempts++
|
||||||
defer func() {
|
defer func() {
|
||||||
if test.cancelContextAfter > 0 && test.cancelContextAfter == attempts {
|
if test.cancelContextAfter > 0 && test.cancelContextAfter == attempts {
|
||||||
cancel()
|
cancel()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return test.callback(attempts)
|
return test.callback(attempts)
|
||||||
})
|
|
||||||
|
|
||||||
if test.errExpected != err {
|
|
||||||
t.Errorf("expected error: %v but got: %v", test.errExpected, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if test.attemptsExpected != attempts {
|
|
||||||
t.Errorf("expected attempts count: %d but got: %d", test.attemptsExpected, attempts)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
if test.errExpected != err {
|
||||||
|
t.Errorf("expected error: %v but got: %v", test.errExpected, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if test.attemptsExpected != attempts {
|
||||||
|
t.Errorf("expected attempts count: %d but got: %d", test.attemptsExpected, attempts)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user