mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-29 16:36:54 +00:00
Call cancel functions to avoid context leaks
Kubernetes-commit: 8dc9619d44ce2074696a4036b2acdc21f3cd0662
This commit is contained in:
parent
6924ba6dfc
commit
f3619f04f1
@ -53,7 +53,9 @@ func TestUntil(t *testing.T) {
|
||||
func(event watch.Event) (bool, error) { return event.Type == watch.Modified, nil },
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
|
||||
if err != nil {
|
||||
t.Fatalf("expected nil error, got %#v", err)
|
||||
@ -80,7 +82,9 @@ func TestUntilMultipleConditions(t *testing.T) {
|
||||
func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Minute)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
|
||||
if err != nil {
|
||||
t.Fatalf("expected nil error, got %#v", err)
|
||||
@ -108,7 +112,9 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
|
||||
func(event watch.Event) (bool, error) { return event.Type == watch.Deleted, nil },
|
||||
}
|
||||
|
||||
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
|
||||
if err != wait.ErrWaitTimeout {
|
||||
t.Fatalf("expected ErrWaitTimeout error, got %#v", err)
|
||||
@ -169,6 +175,7 @@ func TestUntilErrorCondition(t *testing.T) {
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
_, err := UntilWithoutRetry(ctx, fw, conditions...)
|
||||
if err == nil {
|
||||
t.Fatal("expected an error")
|
||||
|
Loading…
Reference in New Issue
Block a user