mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-17 08:41:53 +00:00
Merge pull request #111241 from Abirdcfly/fixtestorsource
make TestListPager_EachListItem rework Kubernetes-commit: ce2c5875d83487eae67896b2ec099bbb9e40395f
This commit is contained in:
commit
46d4284b93
@ -301,16 +301,10 @@ func TestListPager_EachListItem(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "cancel context while processing",
|
name: "cancel context while processing",
|
||||||
fields: fields{PageSize: 10, PageFn: (&testPager{t: t, expectPage: 10, remaining: 51, rv: "rv:20"}).PagedList},
|
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,
|
wantErr: true,
|
||||||
cancelContextOnItem: 3,
|
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")
|
processorErr := fmt.Errorf("processor error")
|
||||||
@ -345,8 +339,7 @@ func TestListPager_EachListItem(t *testing.T) {
|
|||||||
err = p.EachListItem(ctx, metav1.ListOptions{}, fn)
|
err = p.EachListItem(ctx, metav1.ListOptions{}, fn)
|
||||||
}()
|
}()
|
||||||
if (panic != nil) && !tt.wantPanic {
|
if (panic != nil) && !tt.wantPanic {
|
||||||
t.Fatalf(".EachListItem() panic = %v, wantPanic %v", panic, tt.wantPanic)
|
t.Errorf(".EachListItem() panic = %v, wantPanic %v", panic, tt.wantPanic)
|
||||||
} else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
|
Loading…
Reference in New Issue
Block a user