Skip to content

Commit b564eb9

Browse files
Change function name
1 parent 17f20cd commit b564eb9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

iter.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ func (it *v1List[T]) getPage() {
190190
// Query is the function used to get a page listing.
191191
type v1Query[T any] func(*Params, *form.Values) ([]*T, ListContainer, error)
192192

193-
// getV1List returns a new v1List for a given query and its options.
194-
func getV1List[T any](container ListParamsContainer, query v1Query[T]) *v1List[T] {
193+
// newV1List returns a new v1List for a given query and its options, and initializes
194+
// it by fetching the first page of items.
195+
func newV1List[T any](container ListParamsContainer, query v1Query[T]) *v1List[T] {
195196
var listParams *ListParams
196197
formValues := &form.Values{}
197198

iter_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ func TestIterListAndMeta(t *testing.T) {
145145

146146
func TestV1ListEmpty(t *testing.T) {
147147
tq := testV1Query[*int]{{nil, &ListMeta{}, nil}}
148-
g, gerr := collectList(getV1List(nil, tq.query))
148+
g, gerr := collectList(newV1List(nil, tq.query))
149149
assert.Equal(t, 0, len(tq))
150150
assert.Equal(t, 0, len(g))
151151
assert.NoError(t, gerr)
152152
}
153153

154154
func TestV1ListEmptyErr(t *testing.T) {
155155
tq := testV1Query[*int]{{nil, &ListMeta{}, errTest}}
156-
g, gerr := collectList(getV1List(nil, tq.query))
156+
g, gerr := collectList(newV1List(nil, tq.query))
157157
assert.Equal(t, 0, len(tq))
158158
assert.Equal(t, 0, len(g))
159159
assert.Equal(t, errTest, gerr)
@@ -162,7 +162,7 @@ func TestV1ListEmptyErr(t *testing.T) {
162162
func TestV1ListOne(t *testing.T) {
163163
tq := testV1Query[*int]{{[]*int{intPtr(1)}, &ListMeta{}, nil}}
164164
want := []*int{intPtr(1)}
165-
g, gerr := collectList(getV1List(nil, tq.query))
165+
g, gerr := collectList(newV1List(nil, tq.query))
166166
assert.Equal(t, 0, len(tq))
167167
assert.Equal(t, want, g)
168168
assert.NoError(t, gerr)
@@ -171,7 +171,7 @@ func TestV1ListOne(t *testing.T) {
171171
func TestV1ListOneErr(t *testing.T) {
172172
tq := testV1Query[*int]{{[]*int{intPtr(1)}, &ListMeta{}, errTest}}
173173
want := []*int{intPtr(1)}
174-
g, gerr := collectList(getV1List(nil, tq.query))
174+
g, gerr := collectList(newV1List(nil, tq.query))
175175
assert.Equal(t, 0, len(tq))
176176
assert.Equal(t, want, g)
177177
assert.Equal(t, errTest, gerr)
@@ -183,7 +183,7 @@ func TestV1ListPage2EmptyErr(t *testing.T) {
183183
{nil, &ListMeta{}, errTest},
184184
}
185185
want := []*item{{"x"}}
186-
g, gerr := collectList(getV1List(nil, tq.query))
186+
g, gerr := collectList(newV1List(nil, tq.query))
187187
assert.Equal(t, 0, len(tq))
188188
assert.Equal(t, want, g)
189189
assert.Equal(t, errTest, gerr)
@@ -195,7 +195,7 @@ func TestV1ListTwoPages(t *testing.T) {
195195
{[]*item{{"y"}}, &ListMeta{}, nil},
196196
}
197197
want := []*item{{"x"}, {"y"}}
198-
g, gerr := collectList(getV1List(nil, tq.query))
198+
g, gerr := collectList(newV1List(nil, tq.query))
199199
assert.Equal(t, 0, len(tq))
200200
assert.Equal(t, want, g)
201201
assert.NoError(t, gerr)
@@ -207,7 +207,7 @@ func TestV1ListTwoPagesErr(t *testing.T) {
207207
{[]*item{{"y"}}, &ListMeta{}, errTest},
208208
}
209209
want := []*item{{"x"}, {"y"}}
210-
g, gerr := collectList(getV1List(nil, tq.query))
210+
g, gerr := collectList(newV1List(nil, tq.query))
211211
assert.Equal(t, 0, len(tq))
212212
assert.Equal(t, want, g)
213213
assert.Equal(t, errTest, gerr)
@@ -216,7 +216,7 @@ func TestV1ListTwoPagesErr(t *testing.T) {
216216
func TestV1ListReversed(t *testing.T) {
217217
tq := testV1Query[*int]{{[]*int{intPtr(1), intPtr(2)}, &ListMeta{}, nil}}
218218
want := []*int{intPtr(2), intPtr(1)}
219-
g, gerr := collectList(getV1List(&ListParams{EndingBefore: String("x")}, tq.query))
219+
g, gerr := collectList(newV1List(&ListParams{EndingBefore: String("x")}, tq.query))
220220
assert.Equal(t, 0, len(tq))
221221
assert.Equal(t, want, g)
222222
assert.NoError(t, gerr)
@@ -228,7 +228,7 @@ func TestV1ListReversedTwoPages(t *testing.T) {
228228
{[]*item{{"1"}, {"2"}}, &ListMeta{}, nil},
229229
}
230230
want := []*item{{"4"}, {"3"}, {"2"}, {"1"}}
231-
g, gerr := collectList(getV1List(&ListParams{EndingBefore: String("x")}, tq.query))
231+
g, gerr := collectList(newV1List(&ListParams{EndingBefore: String("x")}, tq.query))
232232
assert.Equal(t, 0, len(tq))
233233
assert.Equal(t, want, g)
234234
assert.NoError(t, gerr)

0 commit comments

Comments
 (0)