| 87 | func (apiInt) DeepCopyObject() runtime.Object { return nil } |
| 88 | |
| 89 | func 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 | |
| 120 | type byEventTypeAndName []watch.Event |
| 121 | |