(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestServerPaginateBasic(t *testing.T) { |
| 70 | testCases := []struct { |
| 71 | name string |
| 72 | initialItems []*testItem |
| 73 | inputCursor string |
| 74 | inputPageSize int |
| 75 | wantFeatures []*testItem |
| 76 | wantNextCursor string |
| 77 | wantErr bool |
| 78 | }{ |
| 79 | { |
| 80 | name: "FirstPage_DefaultSize_Full", |
| 81 | initialItems: allTestItems, |
| 82 | inputCursor: "", |
| 83 | inputPageSize: 5, |
| 84 | wantFeatures: allTestItems[0:5], |
| 85 | wantNextCursor: getCursor("echo"), // Based on last item of first page |
| 86 | wantErr: false, |
| 87 | }, |
| 88 | { |
| 89 | name: "SecondPage_DefaultSize_Full", |
| 90 | initialItems: allTestItems, |
| 91 | inputCursor: getCursor("echo"), |
| 92 | inputPageSize: 5, |
| 93 | wantFeatures: allTestItems[5:10], |
| 94 | wantNextCursor: getCursor("juliet"), // Based on last item of second page |
| 95 | wantErr: false, |
| 96 | }, |
| 97 | { |
| 98 | name: "SecondPage_DefaultSize_Full_OutOfOrder", |
| 99 | initialItems: append(allTestItems[5:], allTestItems[0:5]...), |
| 100 | inputCursor: getCursor("echo"), |
| 101 | inputPageSize: 5, |
| 102 | wantFeatures: allTestItems[5:10], |
| 103 | wantNextCursor: getCursor("juliet"), // Based on last item of second page |
| 104 | wantErr: false, |
| 105 | }, |
| 106 | { |
| 107 | name: "SecondPage_DefaultSize_Full_Duplicates", |
| 108 | initialItems: append(allTestItems, allTestItems[0:5]...), |
| 109 | inputCursor: getCursor("echo"), |
| 110 | inputPageSize: 5, |
| 111 | wantFeatures: allTestItems[5:10], |
| 112 | wantNextCursor: getCursor("juliet"), // Based on last item of second page |
| 113 | wantErr: false, |
| 114 | }, |
| 115 | { |
| 116 | name: "LastPage_Remaining", |
| 117 | initialItems: allTestItems, |
| 118 | inputCursor: getCursor("juliet"), |
| 119 | inputPageSize: 5, |
| 120 | wantFeatures: allTestItems[10:11], // Only 1 item left |
| 121 | wantNextCursor: "", // No more pages |
| 122 | wantErr: false, |
| 123 | }, |
| 124 | { |
| 125 | name: "PageSize_1", |
| 126 | initialItems: allTestItems, |
nothing calls this directly
no test coverage detected
searching dependent graphs…