mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #111241 from Abirdcfly/fixtestorsource
make TestListPager_EachListItem rework
This commit is contained in:
commit
ce2c5875d8
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user