Skip to content

Commit

Permalink
test: add filter test case to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jyny committed Oct 4, 2021
1 parent b4f9620 commit a930741
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
29 changes: 29 additions & 0 deletions paginator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,35 @@ func TestPaginator_Paginator(t *testing.T) {
},
wantErr: false,
},
{
name: "Filter Page 2",
fields: fields{
Page: Page{
Number: 2,
Size: 2,
},
Filter: map[string]string{
"active": "true",
},
},
args: args{
dest: []*tests.User{},
},
wantPage: Page{
Number: 2,
Size: 2,
Total: 2,
},
wantDest: []*tests.User{
{
Name: "John",
},
{
Name: "Julia",
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
15 changes: 10 additions & 5 deletions seed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ import "gorm.io/gorm/utils/tests"

var mockUsers = []tests.User{
{
Name: "Jane",
Name: "Jane",
Active: false,
},
{
Name: "Jack",
Name: "Jack",
Active: true,
},
{
Name: "Jill",
Name: "Jill",
Active: true,
},
{
Name: "John",
Name: "John",
Active: true,
},
{
Name: "Julia",
Name: "Julia",
Active: true,
},
}

0 comments on commit a930741

Please sign in to comment.