Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a38ce71

Browse files
committed
Self-review
Signed-off-by: Danny Kopping <[email protected]>
1 parent fd534f1 commit a38ce71

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

coderd/apidoc/docs.go

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/httpmw/notificationtemplateparam.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type notificationTemplateParamContextKey struct{}
1515
func NotificationTemplateParam(r *http.Request) database.NotificationTemplate {
1616
template, ok := r.Context().Value(notificationTemplateParamContextKey{}).(database.NotificationTemplate)
1717
if !ok {
18-
panic("developer error: notification template param middleware not provided")
18+
panic("developer error: notification template middleware not used")
1919
}
2020
return template
2121
}
@@ -29,7 +29,7 @@ func ExtractNotificationTemplateParam(db database.Store) func(http.Handler) http
2929
if !parsed {
3030
return
3131
}
32-
nt, err := db.GetNotificationTemplateById(r.Context(), notifTemplateID)
32+
nt, err := db.GetNotificationTemplateByID(r.Context(), notifTemplateID)
3333
if httpapi.Is404Error(err) {
3434
httpapi.ResourceNotFound(rw)
3535
return

docs/api/enterprise.md

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/notifications.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
)
1616

1717
// @Summary Update notification template dispatch method
18-
// @ID post-notification-template-method
18+
// @ID put-notification-template-method
1919
// @Security CoderSessionToken
2020
// @Produce json
2121
// @Tags Enterprise
2222
// @Success 200
23+
// @Success 304
2324
// @Router /notifications/templates/{notification_template}/method [put]
2425
func (api *API) updateNotificationTemplateMethod(rw http.ResponseWriter, r *http.Request) {
25-
// TODO: authorization (restrict to admin/template admin?)
2626
var (
2727
ctx = r.Context()
2828
template = httpmw.NotificationTemplateParam(r)
@@ -74,7 +74,7 @@ func (api *API) updateNotificationTemplateMethod(rw http.ResponseWriter, r *http
7474

7575
err := api.Database.InTx(func(tx database.Store) error {
7676
var err error
77-
template, err = api.Database.UpdateNotificationTemplateMethodById(r.Context(), database.UpdateNotificationTemplateMethodByIdParams{
77+
template, err = api.Database.UpdateNotificationTemplateMethodByID(r.Context(), database.UpdateNotificationTemplateMethodByIDParams{
7878
ID: template.ID,
7979
Method: nm,
8080
})

enterprise/coderd/notifications_test.go

+3-12
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ import (
1212

1313
"github.com/coder/coder/v2/coderd/coderdtest"
1414
"github.com/coder/coder/v2/coderd/database"
15-
"github.com/coder/coder/v2/coderd/database/dbmem"
1615
"github.com/coder/coder/v2/coderd/database/dbtestutil"
17-
"github.com/coder/coder/v2/coderd/database/pubsub"
1816
"github.com/coder/coder/v2/coderd/notifications"
1917
"github.com/coder/coder/v2/codersdk"
2018
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
@@ -24,21 +22,14 @@ import (
2422
func createOpts(t *testing.T, usePostgres bool) *coderdenttest.Options {
2523
t.Helper()
2624

27-
var (
28-
db database.Store
29-
ps pubsub.Pubsub
30-
)
31-
3225
if usePostgres {
3326
if !dbtestutil.WillUsePostgres() {
3427
t.Skip("This test requires postgres; it relies on read from and writing to the notification_templates table")
3528
}
36-
37-
db, ps = dbtestutil.NewDB(t)
38-
} else {
39-
db, ps = dbmem.New(), pubsub.NewInMemory()
4029
}
4130

31+
db, ps := dbtestutil.NewDB(t)
32+
4233
dt := coderdtest.DeploymentValues(t)
4334
dt.Experiments = []string{string(codersdk.ExperimentNotifications)}
4435
return &coderdenttest.Options{
@@ -83,7 +74,7 @@ func TestUpdateNotificationTemplateMethod(t *testing.T) {
8374
t.Run("Insufficient permissions", func(t *testing.T) {
8475
t.Parallel()
8576

86-
ctx := testutil.Context(t, testutil.WaitShort)
77+
ctx := testutil.Context(t, testutil.WaitSuperLong)
8778

8879
// Given: the first user which has an "owner" role, and another user which does not.
8980
api, firstUser := coderdenttest.New(t, createOpts(t, false))

0 commit comments

Comments
 (0)