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

Function TestUntilMultipleConditions

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

Source from the content-addressed store, hash-verified

72}
73
74func TestUntilMultipleConditions(t *testing.T) {
75 fw := watch.NewFake()
76 go func() {
77 var obj *fakePod
78 fw.Add(obj)
79 }()
80 conditions := []ConditionFunc{
81 func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
82 func(event watch.Event) (bool, error) { return event.Type == watch.Added, nil },
83 }
84
85 ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
86 defer cancel()
87
88 lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
89 if err != nil {
90 t.Fatalf("expected nil error, got %#v", err)
91 }
92 if lastEvent == nil {
93 t.Fatal("expected an event")
94 }
95 if lastEvent.Type != watch.Added {
96 t.Fatalf("expected MODIFIED event type, got %v", lastEvent.Type)
97 }
98 if got, isPod := lastEvent.Object.(*fakePod); !isPod {
99 t.Fatalf("expected a pod event, got %#v", got)
100 }
101}
102
103func TestUntilMultipleConditionsFail(t *testing.T) {
104 fw := watch.NewFake()

Callers

nothing calls this directly

Calls 2

UntilWithoutRetryFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected