MCPcopy Create free account
hub / github.com/coder/coder / TestPagination_asRequestOption

Function TestPagination_asRequestOption

codersdk/pagination_internal_test.go:13–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestPagination_asRequestOption(t *testing.T) {
14 t.Parallel()
15
16 uuid1 := uuid.New()
17 type fields struct {
18 AfterID uuid.UUID
19 Limit int
20 Offset int
21 }
22 tests := []struct {
23 name string
24 fields fields
25 want url.Values
26 }{
27 {
28 name: "Test AfterID is set",
29 fields: fields{AfterID: uuid1},
30 want: url.Values{"after_id": []string{uuid1.String()}},
31 },
32 {
33 name: "Test Limit is set",
34 fields: fields{Limit: 10},
35 want: url.Values{"limit": []string{"10"}},
36 },
37 {
38 name: "Test Offset is set",
39 fields: fields{Offset: 10},
40 want: url.Values{"offset": []string{"10"}},
41 },
42 }
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 t.Parallel()
46
47 p := Pagination{
48 AfterID: tt.fields.AfterID,
49 Limit: tt.fields.Limit,
50 Offset: tt.fields.Offset,
51 }
52 req := httptest.NewRequest(http.MethodGet, "/", nil)
53 p.asRequestOption()(req)
54 got := req.URL.Query()
55 assert.Equal(t, tt.want, got)
56 })
57 }
58}

Callers

nothing calls this directly

Calls 5

asRequestOptionMethod · 0.95
NewMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected