ensure the watch delivers the requested and only the requested items.
(t *testing.T, w watch.Interface, rvs []string, done *sync.WaitGroup)
| 27 | |
| 28 | // ensure the watch delivers the requested and only the requested items. |
| 29 | func 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 | |
| 51 | func TestRCNumber(t *testing.T) { |
| 52 | pod := func(name string) *v1.Pod { |
no test coverage detected