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

Function consume

tools/cache/testing/fake_controller_source_test.go:29–49  ·  view source on GitHub ↗

ensure the watch delivers the requested and only the requested items.

(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup)

Source from the content-addressed store, hash-verified

27
28// ensure the watch delivers the requested and only the requested items.
29func consume(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup) {
30 defer done.Done()
31 for _, rv := range rvs {
32 got, ok := <-w.ResultChan()
33 if !ok {
34 t.Errorf("%#v: unexpected channel close, wanted %v", rvs, rv)
35 return
36 }
37 gotRV := got.Object.(*v1.Pod).ObjectMeta.ResourceVersion
38 if e, a := rv, gotRV; e != a {
39 t.Errorf("wanted %v, got %v", e, a)
40 } else {
41 t.Logf("Got %v as expected", gotRV)
42 }
43 }
44 // We should not get anything else.
45 got, open := <-w.ResultChan()
46 if open {
47 t.Errorf("%#v: unwanted object %#v", rvs, got)
48 }
49}
50
51func TestRCNumber(t *testing.T) {
52 pod := func(name string) *v1.Pod {

Callers 1

TestRCNumberFunction · 0.85

Calls 4

DoneMethod · 0.65
ErrorfMethod · 0.65
LogfMethod · 0.65
ResultChanMethod · 0.45

Tested by

no test coverage detected