Skip to content

Commit 50e459f

Browse files
committed
added tests
1 parent 5c39967 commit 50e459f

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

recipe/thirdparty/users_test.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestGetUsersOldesFirst(t *testing.T) {
7272

7373
unittesting.SigninupCustomRequest(testServer.URL, "test@gmail.com", "testPass0")
7474
unittesting.SigninupCustomRequest(testServer.URL, "test1@gmail.com", "testPass1")
75-
unittesting.SigninupCustomRequest(testServer.URL, "test2@gmail.com", "testPass2")
75+
unittesting.SigninupCustomRequest(testServer.URL, "john@gmail.com", "testPass2")
7676
unittesting.SigninupCustomRequest(testServer.URL, "test3@gmail.com", "testPass3")
7777
unittesting.SigninupCustomRequest(testServer.URL, "test4@gmail.com", "testPass4")
7878

@@ -122,6 +122,24 @@ func TestGetUsersOldesFirst(t *testing.T) {
122122
} else {
123123
t.Fail()
124124
}
125+
126+
customLimit = 10
127+
query := make(map[string]string)
128+
query["email"] = "doe"
129+
userPaginationResult, err = supertokens.GetUsersOldestFirst(nil, &customLimit, nil, query)
130+
if err != nil {
131+
t.Fail()
132+
} else {
133+
assert.Equal(t, len(userPaginationResult.Users), 0)
134+
}
135+
136+
query["email"] = "john"
137+
userPaginationResult, err = supertokens.GetUsersOldestFirst(nil, &customLimit, nil, query)
138+
if err != nil {
139+
t.Fail()
140+
} else {
141+
assert.Equal(t, len(userPaginationResult.Users), 1)
142+
}
125143
}
126144

127145
func TestGetUsersNewestFirst(t *testing.T) {
@@ -167,7 +185,7 @@ func TestGetUsersNewestFirst(t *testing.T) {
167185

168186
unittesting.SigninupCustomRequest(testServer.URL, "test@gmail.com", "testPass0")
169187
unittesting.SigninupCustomRequest(testServer.URL, "test1@gmail.com", "testPass1")
170-
unittesting.SigninupCustomRequest(testServer.URL, "test2@gmail.com", "testPass2")
188+
unittesting.SigninupCustomRequest(testServer.URL, "john@gmail.com", "testPass2")
171189
unittesting.SigninupCustomRequest(testServer.URL, "test3@gmail.com", "testPass3")
172190
unittesting.SigninupCustomRequest(testServer.URL, "test4@gmail.com", "testPass4")
173191

@@ -218,6 +236,24 @@ func TestGetUsersNewestFirst(t *testing.T) {
218236
} else {
219237
t.Fail()
220238
}
239+
240+
customLimit = 10
241+
query := make(map[string]string)
242+
query["email"] = "doe"
243+
userPaginationResult, err = supertokens.GetUsersNewestFirst(nil, &customLimit, nil, query)
244+
if err != nil {
245+
t.Fail()
246+
} else {
247+
assert.Equal(t, len(userPaginationResult.Users), 0)
248+
}
249+
250+
query["email"] = "john"
251+
userPaginationResult, err = supertokens.GetUsersNewestFirst(nil, &customLimit, nil, query)
252+
if err != nil {
253+
t.Fail()
254+
} else {
255+
assert.Equal(t, len(userPaginationResult.Users), 1)
256+
}
221257
}
222258

223259
func TestGetUserCount(t *testing.T) {

0 commit comments

Comments
 (0)