Skip to content

Commit fac16a5

Browse files
committed
Add test for userparam getting
1 parent 5302128 commit fac16a5

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

coderd/users.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ func (users *users) userOrganizations(rw http.ResponseWriter, r *http.Request) {
144144
user := httpmw.UserParam(r)
145145

146146
organizations, err := users.Database.GetOrganizationsByUserID(r.Context(), user.ID)
147-
if errors.Is(err, sql.ErrNoRows) {
148-
err = nil
149-
}
150147
if err != nil {
151148
httpapi.Write(rw, http.StatusInternalServerError, httpapi.Response{
152149
Message: fmt.Sprintf("get organizations: %s", err.Error()),

httpmw/userparam_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ func TestUserParam(t *testing.T) {
9090
routeContext.URLParams.Add("user", "me")
9191
r = r.WithContext(context.WithValue(r.Context(), chi.RouteCtxKey, routeContext))
9292
httpmw.ExtractUserParam(db)(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
93+
_ = httpmw.UserParam(r)
9394
rw.WriteHeader(http.StatusOK)
9495
})).ServeHTTP(rw, r)
9596
res := rw.Result()

0 commit comments

Comments
 (0)