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())
|
||||
}
|
||||
|
||||
type logReaderIterator struct {
|
||||
rcs []io.ReadCloser
|
||||
// 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 (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) {
|
||||
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,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue