Merge pull request #111241 from Abirdcfly/fixtestorsource

make TestListPager_EachListItem rework
This commit is contained in:
Kubernetes Prow Robot 2022-08-26 13:38:34 -07:00 committed by GitHub
commit ce2c5875d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,16 +301,10 @@ func TestListPager_EachListItem(t *testing.T) {
{
name: "cancel context while processing",
fields: fields{PageSize: 10, PageFn: (&testPager{t: t, expectPage: 10, remaining: 51, rv: "rv:20"}).PagedList},
want: list(3, "rv:20"), // all the items <= the one the processor returned an error on should have been visited
want: list(10, "rv:20"), // The whole PageSize worth of items got returned.
wantErr: true,
cancelContextOnItem: 3,
},
{
name: "panic processing item",
fields: fields{PageSize: 10, PageFn: (&testPager{t: t, expectPage: 10, remaining: 51, rv: "rv:20"}).PagedList},
want: list(3, "rv:20"), // all the items <= the one the processor returned an error on should have been visited
wantPanic: true,
},
}
processorErr := fmt.Errorf("processor error")
@ -345,8 +339,7 @@ func TestListPager_EachListItem(t *testing.T) {
err = p.EachListItem(ctx, metav1.ListOptions{}, fn)
}()
if (panic != nil) && !tt.wantPanic {
t.Fatalf(".EachListItem() panic = %v, wantPanic %v", panic, tt.wantPanic)
} else {
t.Errorf(".EachListItem() panic = %v, wantPanic %v", panic, tt.wantPanic)
return
}
if (err != nil) != tt.wantErr {