Skip to content

feat: support created_at filter for the GET /users endpoint #15633

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 17 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
Commits
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
use nil org ID slice on dbmem API to compare equal
  • Loading branch information
ethanndickson committed Dec 17, 2024
commit 981656f12fe18f90d6ddf7667add9cbfc54061f7
12 changes: 12 additions & 0 deletions coderd/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"github.com/coder/coder/v2/coderd/database/dbauthz"
"github.com/coder/coder/v2/coderd/database/dbfake"
"github.com/coder/coder/v2/coderd/database/dbgen"
"github.com/coder/coder/v2/coderd/database/dbtestutil"
"github.com/coder/coder/v2/coderd/database/dbtime"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/coderd/util/ptr"
Expand Down Expand Up @@ -1776,6 +1777,17 @@
exp = append(exp, made)
}
}

// TODO: This can be removed with dbmem
if !dbtestutil.WillUsePostgres() {
Copy link
Member

@ethanndickson ethanndickson Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan is to eventually get rid of dbmem entirely, so I'm not too worried about cluttering up this test. I've used dbtestutil.WillUsePostgres as it's more likely to found and removed when that happens.

This is to handle a disparity between organization-less members in Postgres and dbmem. For dbmem, the API returns an empty slice. For postgres it returns nil. (FWIW it's not possible to have organization-less members on a real Coder deployment.)

for i := range matched.Users {

Check failure on line 1783 in coderd/users_test.go

View workflow job for this annotation

GitHub Actions / lint

empty-lines: extra empty line at the end of a block (revive)
if len(matched.Users[i].OrganizationIDs) == 0 {
matched.Users[i].OrganizationIDs = nil
}

}
}

require.ElementsMatch(t, exp, matched.Users, "expected users returned")
})
}
Expand Down
Loading