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

Function TestUntilErrorCondition

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

Source from the content-addressed store, hash-verified

162}
163
164func TestUntilErrorCondition(t *testing.T) {
165 fw := watch.NewFake()
166 go func() {
167 var obj *fakePod
168 fw.Add(obj)
169 }()
170 expected := "something bad"
171 conditions := []ConditionFunc{
172 func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
173 func(event watch.Event) (bool, error) { return false, errors.New(expected) },
174 }
175
176 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
177 defer cancel()
178
179 _, err := UntilWithoutRetry(ctx, fw, conditions...)
180 if err == nil {
181 t.Fatal("expected an error")
182 }
183 if !strings.Contains(err.Error(), expected) {
184 t.Fatalf("expected %q in error string, got %q", expected, err.Error())
185 }
186}
187
188func TestUntilWithSync(t *testing.T) {
189 // FIXME: test preconditions

Callers

nothing calls this directly

Calls 3

UntilWithoutRetryFunction · 0.85
AddMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected