MCPcopy
hub / github.com/kubernetes/client-go / TestUntilMultipleConditionsFail

Function TestUntilMultipleConditionsFail

tools/watch/until_test.go:103–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestUntilMultipleConditionsFail(t *testing.T) {
104 fw := watch.NewFake()
105 go func() {
106 var obj *fakePod
107 fw.Add(obj)
108 }()
109 conditions := []ConditionFunc{
110 func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
111 func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
112 func(event watch.Event) (bool, error) { return event.Type == watch.Deleted, nil },
113 }
114
115 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
116 defer cancel()
117
118 lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
119 if err != wait.ErrWaitTimeout {
120 t.Fatalf("expected ErrWaitTimeout error, got %#v", err)
121 }
122 if lastEvent == nil {
123 t.Fatal("expected an event")
124 }
125 if lastEvent.Type != watch.Added {
126 t.Fatalf("expected ADDED event type, got %v", lastEvent.Type)
127 }
128 if got, isPod := lastEvent.Object.(*fakePod); !isPod {
129 t.Fatalf("expected a pod event, got %#v", got)
130 }
131}
132
133func TestUntilTimeout(t *testing.T) {
134 fw := watch.NewFake()

Callers

nothing calls this directly

Calls 2

UntilWithoutRetryFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected