(ctx context.Context, options metav1.ListOptions)
| 63 | } |
| 64 | |
| 65 | func (p *testPager) PagedList(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) { |
| 66 | if p.done { |
| 67 | p.t.Errorf("did not expect additional call to paged list") |
| 68 | return nil, fmt.Errorf("unexpected list call") |
| 69 | } |
| 70 | expectedContinue := fmt.Sprintf("%s:%d", p.rv, p.last) |
| 71 | if options.Limit != p.expectPage || (p.continuing && options.Continue != expectedContinue) { |
| 72 | p.t.Errorf("invariant violated, expected limit %d and continue %s, got %#v", p.expectPage, expectedContinue, options) |
| 73 | return nil, fmt.Errorf("invariant violated") |
| 74 | } |
| 75 | var list metainternalversion.List |
| 76 | total := options.Limit |
| 77 | if total == 0 { |
| 78 | total = int64(p.remaining) |
| 79 | } |
| 80 | for i := int64(0); i < total; i++ { |
| 81 | if p.remaining <= 0 { |
| 82 | break |
| 83 | } |
| 84 | list.Items = append(list.Items, &metav1beta1.PartialObjectMetadata{ |
| 85 | ObjectMeta: metav1.ObjectMeta{ |
| 86 | Name: fmt.Sprintf("%d", p.index), |
| 87 | }, |
| 88 | }) |
| 89 | p.remaining-- |
| 90 | p.index++ |
| 91 | } |
| 92 | p.last = p.index |
| 93 | if p.remaining > 0 { |
| 94 | list.Continue = fmt.Sprintf("%s:%d", p.rv, p.last) |
| 95 | p.continuing = true |
| 96 | } else { |
| 97 | p.done = true |
| 98 | } |
| 99 | list.ResourceVersion = p.rv |
| 100 | return &list, nil |
| 101 | } |
| 102 | |
| 103 | func (p *testPager) ExpiresOnSecondPage(ctx context.Context, options metav1.ListOptions) (runtime.Object, error) { |
| 104 | if p.continuing { |
no test coverage detected