Merge pull request #111241 from Abirdcfly/fixtestorsource

make TestListPager_EachListItem rework

Kubernetes-commit: ce2c5875d83487eae67896b2ec099bbb9e40395f
This commit is contained in:
Kubernetes Publisher 2022-08-26 13:38:34 -07:00
commit 46d4284b93

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 {