(t *testing.T)
| 71 | } |
| 72 | |
| 73 | func TestRunUntil(t *testing.T) { |
| 74 | stopCh := make(chan struct{}) |
| 75 | store := NewStore(MetaNamespaceKeyFunc) |
| 76 | r := NewReflector(&testLW{}, &v1.Pod{}, store, 0) |
| 77 | fw := watch.NewFake() |
| 78 | r.listerWatcher = &testLW{ |
| 79 | WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { |
| 80 | return fw, nil |
| 81 | }, |
| 82 | ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { |
| 83 | return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil |
| 84 | }, |
| 85 | } |
| 86 | go r.Run(stopCh) |
| 87 | // Synchronously add a dummy pod into the watch channel so we |
| 88 | // know the RunUntil go routine is in the watch handler. |
| 89 | fw.Add(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}}) |
| 90 | close(stopCh) |
| 91 | select { |
| 92 | case _, ok := <-fw.ResultChan(): |
| 93 | if ok { |
| 94 | t.Errorf("Watch channel left open after stopping the watch") |
| 95 | } |
| 96 | case <-time.After(wait.ForeverTestTimeout): |
| 97 | t.Errorf("the cancellation is at least %s late", wait.ForeverTestTimeout.String()) |
| 98 | break |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func TestReflectorResyncChan(t *testing.T) { |
| 103 | s := NewStore(MetaNamespaceKeyFunc) |
nothing calls this directly
no test coverage detected