Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: Implement unified pagination and add template versions support #1308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 10, 2022
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
475dcf9
feat: Implement pagination for template versions
mafredri May 5, 2022
01a52d1
Use codersdk.Pagination in users endpoint
mafredri May 5, 2022
d1478a9
Avoid user sort side-effect in databasefake
mafredri May 5, 2022
7a36610
Return sql.ErrNoRows for GetUsers in databasefake
mafredri May 5, 2022
61c60c6
Sync codepaths in databasefake
mafredri May 5, 2022
62fa273
Fix test with better handling of sql.ErrNoRows in coderd
mafredri May 5, 2022
878d633
Remove an unused require.NoError
mafredri May 5, 2022
5c840fd
Return empty list for sql.ErrNoRows in coderd users endpoint
mafredri May 5, 2022
07e590c
Add t.Parallel() to sub tests
mafredri May 5, 2022
be8ba6c
Reinit tt due to parallel test
mafredri May 5, 2022
5ab9ad5
Remove unused variable
mafredri May 5, 2022
e2a3741
Fix copy pasta in query comments
mafredri May 5, 2022
61410a5
Move ParsePagination from httpapi to coderd and unexport, return code…
mafredri May 5, 2022
8a67746
codersdk: Create requestOption type
mafredri May 5, 2022
55028d2
codersdk: Add test for Pagination.asRequestOption
mafredri May 5, 2022
ea2371e
coderd: Handle http response errors in parsePagination
mafredri May 5, 2022
66af4ec
codersdk: Use parallel test
mafredri May 5, 2022
067f912
Fix created_at edge case for pagination cursor in queries
mafredri May 5, 2022
b8be7a8
Fix copy paste issue
mafredri May 5, 2022
13fc406
Run make gen
mafredri May 10, 2022
aab400c
feat: Add support for json omitempty and embedded structs in apitypin…
mafredri May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
codersdk: Add test for Pagination.asRequestOption
  • Loading branch information
mafredri committed May 10, 2022
commit 55028d23f33c2355dcbdaf10abd99410588a1b1a
54 changes: 54 additions & 0 deletions codersdk/pagination_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package codersdk

import (
"net/http"
"net/http/httptest"
"net/url"
"testing"

"github.com/google/uuid"
"github.com/stretchr/testify/assert"
)

func TestPagination_asRequestOption(t *testing.T) {
uuid1 := uuid.New()
type fields struct {
AfterID uuid.UUID
Limit int
Offset int
}
tests := []struct {
name string
fields fields
want url.Values
}{
{
name: "Test AfterID is set",
fields: fields{AfterID: uuid1},
want: url.Values{"after_id": []string{uuid1.String()}},
},
{
name: "Test Limit is set",
fields: fields{Limit: 10},
want: url.Values{"limit": []string{"10"}},
},
{
name: "Test Offset is set",
fields: fields{Offset: 10},
want: url.Values{"offset": []string{"10"}},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := Pagination{
AfterID: tt.fields.AfterID,
Limit: tt.fields.Limit,
Offset: tt.fields.Offset,
}
req := httptest.NewRequest(http.MethodGet, "/", nil)
p.asRequestOption()(req)
got := req.URL.Query()
assert.Equal(t, tt.want, got)
})
}
}