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

Function TestCloseWatchChannelOnError

tools/cache/reflector_test.go:48–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func 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
73func TestRunUntil(t *testing.T) {
74 stopCh := make(chan struct{})

Callers

nothing calls this directly

Calls 7

ListAndWatchMethod · 0.95
NewReflectorFunction · 0.85
NewStoreFunction · 0.85
ErrorMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65
ResultChanMethod · 0.45

Tested by

no test coverage detected