Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7c9ca8

Browse files
committed
Self-review
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent895377b commitb7c9ca8

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

‎coderd/apidoc/docs.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/httpmw/notificationtemplateparam.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type notificationTemplateParamContextKey struct{}
1515
funcNotificationTemplateParam(r*http.Request) database.NotificationTemplate {
1616
template,ok:=r.Context().Value(notificationTemplateParamContextKey{}).(database.NotificationTemplate)
1717
if!ok {
18-
panic("developer error: notification templateparammiddleware notprovided")
18+
panic("developer error: notification template middleware notused")
1919
}
2020
returntemplate
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
ifhttpapi.Is404Error(err) {
3434
httpapi.ResourceNotFound(rw)
3535
return

‎docs/api/enterprise.md

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎enterprise/coderd/notifications.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
)
1616

1717
// @Summary Update notification template dispatch method
18-
// @IDpost-notification-template-method
18+
// @IDput-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
varerrerror
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

Lines changed: 3 additions & 12 deletions
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
funccreateOpts(t*testing.T,usePostgresbool)*coderdenttest.Options {
2523
t.Helper()
2624

27-
var (
28-
db database.Store
29-
ps pubsub.Pubsub
30-
)
31-
3225
ifusePostgres {
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)

[8]ページ先頭

©2009-2025 Movatter.jp