Skip to content

Commit 61c60c6

Browse files
committed
Sync codepaths in databasefake
1 parent 7a36610 commit 61c60c6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

coderd/database/databasefake/databasefake.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,20 @@ func (q *fakeQuerier) GetUsers(_ context.Context, params database.GetUsersParams
177177
copy(users, q.users)
178178

179179
// Database orders by created_at
180-
sort.Slice(users, func(i, j int) bool {
181-
if users[i].CreatedAt.Equal(users[j].CreatedAt) {
180+
slices.SortFunc(users, func(a, b database.User) bool {
181+
if a.CreatedAt.Equal(b.CreatedAt) {
182182
// Technically the postgres database also orders by uuid. So match
183183
// that behavior
184-
return users[i].ID.String() < users[j].ID.String()
184+
return a.ID.String() < b.ID.String()
185185
}
186-
return users[i].CreatedAt.Before(users[j].CreatedAt)
186+
return a.CreatedAt.Before(b.CreatedAt)
187187
})
188188

189189
if params.AfterUser != uuid.Nil {
190190
found := false
191-
for i := range users {
192-
if users[i].ID == params.AfterUser {
191+
for i, v := range users {
192+
if v.ID == params.AfterUser {
193193
// We want to return all users after index i.
194-
if i+1 >= len(users) {
195-
return []database.User{}, nil
196-
}
197194
users = users[i+1:]
198195
found = true
199196
break

0 commit comments

Comments
 (0)