(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestCloseWatchChannelOnError(t *testing.T) { |
| 49 | r := NewReflector(&testLW{}, &v1.Pod{}, NewStore(MetaNamespaceKeyFunc), 0) |
| 50 | pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "bar"}} |
| 51 | fw := watch.NewFake() |
| 52 | r.listerWatcher = &testLW{ |
| 53 | WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { |
| 54 | return fw, nil |
| 55 | }, |
| 56 | ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { |
| 57 | return &v1.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}, nil |
| 58 | }, |
| 59 | } |
| 60 | go r.ListAndWatch(wait.NeverStop) |
| 61 | fw.Error(pod) |
| 62 | select { |
| 63 | case _, ok := <-fw.ResultChan(): |
| 64 | if ok { |
| 65 | t.Errorf("Watch channel left open after cancellation") |
| 66 | } |
| 67 | case <-time.After(wait.ForeverTestTimeout): |
| 68 | t.Errorf("the cancellation is at least %s late", wait.ForeverTestTimeout.String()) |
| 69 | break |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | func TestRunUntil(t *testing.T) { |
| 74 | stopCh := make(chan struct{}) |
nothing calls this directly
no test coverage detected