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

Commit0a66915

Browse files
test: test behaviour
1 parente6b48c3 commit0a66915

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

‎coderd/database/dbmem/dbmem.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,14 +5623,14 @@ func (q *FakeQuerier) GetUsersWithAccessToTemplateByID(ctx context.Context, id u
56235623
q.mutex.RLock()
56245624
deferq.mutex.RUnlock()
56255625

5626-
groups:=make(map[string]bool,0)
5626+
groups:=make(map[string]struct{},0)
56275627
for_,template:=rangeq.templates {
56285628
iftemplate.ID!=id {
56295629
continue
56305630
}
56315631

56325632
forgroup:=rangetemplate.GroupACL {
5633-
groups[group]=true
5633+
groups[group]=struct{}{}
56345634
}
56355635
}
56365636

‎enterprise/coderd/templates_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"net/http"
7+
"slices"
78
"testing"
89
"time"
910

@@ -38,17 +39,19 @@ func TestTemplates(t *testing.T) {
3839
t.Run("Deprecated",func(t*testing.T) {
3940
t.Parallel()
4041

42+
notifyEnq:=&testutil.FakeNotificationsEnqueuer{}
4143
owner,user:=coderdenttest.New(t,&coderdenttest.Options{
4244
Options:&coderdtest.Options{
4345
IncludeProvisionerDaemon:true,
46+
NotificationsEnqueuer:notifyEnq,
4447
},
4548
LicenseOptions:&coderdenttest.LicenseOptions{
4649
Features: license.Features{
4750
codersdk.FeatureAccessControl:1,
4851
},
4952
},
5053
})
51-
client,_:=coderdtest.CreateAnotherUser(t,owner,user.OrganizationID,rbac.RoleTemplateAdmin())
54+
client,anotherUser:=coderdtest.CreateAnotherUser(t,owner,user.OrganizationID,rbac.RoleTemplateAdmin())
5255
version:=coderdtest.CreateTemplateVersion(t,client,user.OrganizationID,nil)
5356
template:=coderdtest.CreateTemplate(t,client,user.OrganizationID,version.ID)
5457
coderdtest.AwaitTemplateVersionJobCompleted(t,client,version.ID)
@@ -65,6 +68,25 @@ func TestTemplates(t *testing.T) {
6568
assert.True(t,updated.Deprecated)
6669
assert.NotEmpty(t,updated.DeprecationMessage)
6770

71+
notifs:= []*testutil.Notification{}
72+
for_,notif:=rangenotifyEnq.Sent {
73+
ifnotif.TemplateID==notifications.TemplateTemplateDeprecated {
74+
notifs=append(notifs,notif)
75+
}
76+
}
77+
require.Equal(t,2,len(notifs))
78+
79+
expectedSentTo:= []string{user.UserID.String(),anotherUser.ID.String()}
80+
slices.Sort(expectedSentTo)
81+
82+
sentTo:= []string{}
83+
for_,notif:=rangenotifs {
84+
sentTo=append(sentTo,notif.UserID.String())
85+
}
86+
slices.Sort(sentTo)
87+
88+
assert.Equal(t,expectedSentTo,sentTo)
89+
6890
_,err=client.CreateWorkspace(ctx,user.OrganizationID,codersdk.Me, codersdk.CreateWorkspaceRequest{
6991
TemplateID:template.ID,
7092
Name:"foobar",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp