tests: Replace struct with closure
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
bf49105619
commit
154a13ecfc
|
@ -90,25 +90,22 @@ func TestPodWatcherClose(t *testing.T) {
|
||||||
assert.Equal(t, "[foo] it worked\n", buf.String())
|
assert.Equal(t, "[foo] it worked\n", buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
type logReaderIterator struct {
|
// makeReadCloserIterator returns a function which returns a function which
|
||||||
rcs []io.ReadCloser
|
// 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 (f *logReaderIterator) next() io.ReadCloser {
|
|
||||||
var rc io.ReadCloser
|
|
||||||
rc, f.rcs = f.rcs[0], f.rcs[1:]
|
|
||||||
return rc
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPodWatcherRemovedPod(t *testing.T) {
|
func TestPodWatcherRemovedPod(t *testing.T) {
|
||||||
podsWatcher := watch.NewFake()
|
podsWatcher := watch.NewFake()
|
||||||
|
|
||||||
r1, w1 := io.Pipe()
|
r1, w1 := io.Pipe()
|
||||||
r2, w2 := io.Pipe()
|
r2, w2 := io.Pipe()
|
||||||
it := logReaderIterator{[]io.ReadCloser{r1, r2}}
|
|
||||||
|
|
||||||
clientset := mockClientset{
|
clientset := mockClientset{
|
||||||
getLogsReaderFunc: it.next,
|
getLogsReaderFunc: makeReadCloserIterator(r1, r2),
|
||||||
getLogsStatusCode: http.StatusOK,
|
getLogsStatusCode: http.StatusOK,
|
||||||
podsWatcher: podsWatcher,
|
podsWatcher: podsWatcher,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue