diff --git a/logs/pod_watcher_test.go b/logs/pod_watcher_test.go index fa7bf26..c4e09a7 100644 --- a/logs/pod_watcher_test.go +++ b/logs/pod_watcher_test.go @@ -90,25 +90,22 @@ func TestPodWatcherClose(t *testing.T) { assert.Equal(t, "[foo] it worked\n", buf.String()) } -type logReaderIterator struct { - rcs []io.ReadCloser -} - -func (f *logReaderIterator) next() io.ReadCloser { - var rc io.ReadCloser - rc, f.rcs = f.rcs[0], f.rcs[1:] - return rc +// makeReadCloserIterator returns a function which returns a function which +// iterates through each provided ReadCloser. +func makeReadCloserIterator(rcs ...io.ReadCloser) func() io.ReadCloser { + return func() (rc io.ReadCloser) { + rc, rcs = rcs[0], rcs[1:] + return + } } func TestPodWatcherRemovedPod(t *testing.T) { podsWatcher := watch.NewFake() - r1, w1 := io.Pipe() r2, w2 := io.Pipe() - it := logReaderIterator{[]io.ReadCloser{r1, r2}} clientset := mockClientset{ - getLogsReaderFunc: it.next, + getLogsReaderFunc: makeReadCloserIterator(r1, r2), getLogsStatusCode: http.StatusOK, podsWatcher: podsWatcher, }