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

Function TestUntilTimeout

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

Source from the content-addressed store, hash-verified

131}
132
133func TestUntilTimeout(t *testing.T) {
134 fw := watch.NewFake()
135 go func() {
136 var obj *fakePod
137 fw.Add(obj)
138 fw.Modify(obj)
139 }()
140 conditions := []ConditionFunc{
141 func(event watch.Event) (bool, error) {
142 return event.Type == watch.Added, nil
143 },
144 func(event watch.Event) (bool, error) {
145 return event.Type == watch.Modified, nil
146 },
147 }
148
149 lastEvent, err := UntilWithoutRetry(context.Background(), fw, conditions...)
150 if err != nil {
151 t.Fatalf("expected nil error, got %#v", err)
152 }
153 if lastEvent == nil {
154 t.Fatal("expected an event")
155 }
156 if lastEvent.Type != watch.Modified {
157 t.Fatalf("expected MODIFIED event type, got %v", lastEvent.Type)
158 }
159 if got, isPod := lastEvent.Object.(*fakePod); !isPod {
160 t.Fatalf("expected a pod event, got %#v", got)
161 }
162}
163
164func TestUntilErrorCondition(t *testing.T) {
165 fw := watch.NewFake()

Callers

nothing calls this directly

Calls 3

UntilWithoutRetryFunction · 0.85
ModifyMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected