mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-27 22:27:23 +08:00
test: update tests
This commit is contained in:
@ -103,8 +103,6 @@ type UserListRequest struct {
|
||||
}
|
||||
|
||||
func (h *UserHandlerAdmin) List(c echo.Context) error {
|
||||
// TODO: return 'X-Total-Count' header, which includes the all users count
|
||||
// TODO; return 'Link' header, which includes links to next, previous, current(???), first, last page (example https://docs.github.com/en/rest/guides/traversing-with-pagination)
|
||||
var request UserListRequest
|
||||
err := (&echo.DefaultBinder{}).BindQueryParams(c, &request)
|
||||
if err != nil {
|
||||
|
||||
@ -280,6 +280,7 @@ func TestUserHandlerAdmin_List(t *testing.T) {
|
||||
err := json.Unmarshal(rec.Body.Bytes(), &users)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 2, len(users))
|
||||
assert.Equal(t, "2", rec.Header().Get("X-Total-Count"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,6 +324,7 @@ func TestUserHandlerAdmin_List_Pagination(t *testing.T) {
|
||||
err := json.Unmarshal(rec.Body.Bytes(), &got)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 1, len(got))
|
||||
assert.Equal(t, "2", rec.Header().Get("X-Total-Count"))
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,6 +347,7 @@ func TestUserHandlerAdmin_List_NoUsers(t *testing.T) {
|
||||
err := json.Unmarshal(rec.Body.Bytes(), &got)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(got))
|
||||
assert.Equal(t, "0", rec.Header().Get("X-Total-Count"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -75,3 +75,7 @@ func (p *auditLogPersister) Delete(auditLog models.AuditLog) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *auditLogPersister) Count(startTime *time.Time, endTime *time.Time) (int, error) {
|
||||
return len(p.logs), nil
|
||||
}
|
||||
|
||||
@ -91,3 +91,7 @@ func (p *userPersister) List(page int, perPage int) ([]models.User, error) {
|
||||
}
|
||||
return result[page-1], nil
|
||||
}
|
||||
|
||||
func (p *userPersister) Count() (int, error) {
|
||||
return len(p.users), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user