mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Merge pull request #19226 from wojtek-t/fix_test_poll
Fix TestPoll test
This commit is contained in:
commit
ab58e72333
@ -84,7 +84,7 @@ func TestPoll(t *testing.T) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
})
|
})
|
||||||
fp := fakePoller{max: 1}
|
fp := fakePoller{max: 1}
|
||||||
if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Microsecond), f); err != nil {
|
if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Second), f); err != nil {
|
||||||
t.Fatalf("unexpected error %v", err)
|
t.Fatalf("unexpected error %v", err)
|
||||||
}
|
}
|
||||||
if invocations != 1 {
|
if invocations != 1 {
|
||||||
@ -94,19 +94,18 @@ func TestPoll(t *testing.T) {
|
|||||||
if used != 1 {
|
if used != 1 {
|
||||||
t.Errorf("Expected exactly one tick, got %d", used)
|
t.Errorf("Expected exactly one tick, got %d", used)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPollError(t *testing.T) {
|
||||||
expectedError := errors.New("Expected error")
|
expectedError := errors.New("Expected error")
|
||||||
f = ConditionFunc(func() (bool, error) {
|
f := ConditionFunc(func() (bool, error) {
|
||||||
return false, expectedError
|
return false, expectedError
|
||||||
})
|
})
|
||||||
fp = fakePoller{max: 1}
|
fp := fakePoller{max: 1}
|
||||||
if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Microsecond), f); err == nil || err != expectedError {
|
if err := pollInternal(fp.GetWaitFunc(time.Microsecond, time.Second), f); err == nil || err != expectedError {
|
||||||
t.Fatalf("Expected error %v, got none %v", expectedError, err)
|
t.Fatalf("Expected error %v, got none %v", expectedError, err)
|
||||||
}
|
}
|
||||||
if invocations != 1 {
|
used := atomic.LoadInt32(&fp.used)
|
||||||
t.Errorf("Expected exactly one invocation, got %d", invocations)
|
|
||||||
}
|
|
||||||
used = atomic.LoadInt32(&fp.used)
|
|
||||||
if used != 1 {
|
if used != 1 {
|
||||||
t.Errorf("Expected exactly one tick, got %d", used)
|
t.Errorf("Expected exactly one tick, got %d", used)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user