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

Function TestEventProcessorOrdersEvents

tools/watch/informerwatcher_test.go:89–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87func (apiInt) DeepCopyObject() runtime.Object { return nil }
88
89func TestEventProcessorOrdersEvents(t *testing.T) {
90 out := make(chan watch.Event)
91 e := newEventProcessor(out)
92 go e.run()
93
94 numProcessed := 0
95 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
96 go func() {
97 for i := 0; i < 1000; i++ {
98 e := <-out
99 if got, want := int(e.Object.(apiInt)), i; got != want {
100 t.Errorf("unexpected event: got=%d, want=%d", got, want)
101 }
102 numProcessed++
103 }
104 cancel()
105 }()
106
107 for i := 0; i < 1000; i++ {
108 e.push(watch.Event{Object: apiInt(i)})
109 }
110
111 <-ctx.Done()
112 e.stop()
113
114 if numProcessed != 1000 {
115 t.Errorf("unexpected number of events processed: %d", numProcessed)
116 }
117
118}
119
120type byEventTypeAndName []watch.Event
121

Callers

nothing calls this directly

Calls 7

newEventProcessorFunction · 0.85
apiIntTypeAlias · 0.85
pushMethod · 0.80
stopMethod · 0.80
ErrorfMethod · 0.65
DoneMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected