Skip to content

Commit 5d683d4

Browse files
committed
Review comments
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent e4103c3 commit 5d683d4

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,10 +2711,14 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
27112711
}
27122712

27132713
func (*FakeQuerier) GetNotificationTemplateByID(_ context.Context, _ uuid.UUID) (database.NotificationTemplate, error) {
2714+
// Not implementing this function because it relies on state in the database which is created with migrations.
2715+
// We could consider using code-generation to align the database state and dbmem, but it's not worth it right now.
27142716
return database.NotificationTemplate{}, ErrUnimplemented
27152717
}
27162718

27172719
func (*FakeQuerier) GetNotificationTemplatesByKind(_ context.Context, _ database.NotificationTemplateKind) ([]database.NotificationTemplate, error) {
2720+
// Not implementing this function because it relies on state in the database which is created with migrations.
2721+
// We could consider using code-generation to align the database state and dbmem, but it's not worth it right now.
27182722
return nil, ErrUnimplemented
27192723
}
27202724

@@ -7547,6 +7551,8 @@ func (q *FakeQuerier) UpdateMemberRoles(_ context.Context, arg database.UpdateMe
75477551
}
75487552

75497553
func (*FakeQuerier) UpdateNotificationTemplateMethodByID(_ context.Context, _ database.UpdateNotificationTemplateMethodByIDParams) (database.NotificationTemplate, error) {
7554+
// Not implementing this function because it relies on state in the database which is created with migrations.
7555+
// We could consider using code-generation to align the database state and dbmem, but it's not worth it right now.
75507556
return database.NotificationTemplate{}, ErrUnimplemented
75517557
}
75527558

@@ -8147,7 +8153,7 @@ func (q *FakeQuerier) UpdateUserLoginType(_ context.Context, arg database.Update
81478153
func (q *FakeQuerier) UpdateUserNotificationPreferences(_ context.Context, arg database.UpdateUserNotificationPreferencesParams) (int64, error) {
81488154
err := validateDatabaseType(arg)
81498155
if err != nil {
8150-
return -1, err
8156+
return 0, err
81518157
}
81528158

81538159
q.mutex.Lock()
@@ -8171,7 +8177,7 @@ func (q *FakeQuerier) UpdateUserNotificationPreferences(_ context.Context, arg d
81718177
}
81728178

81738179
np.Disabled = disabled
8174-
np.UpdatedAt = time.Now()
8180+
np.UpdatedAt = dbtime.Now()
81758181
q.notificationPreferences[j] = np
81768182

81778183
upserted++
@@ -8184,8 +8190,8 @@ func (q *FakeQuerier) UpdateUserNotificationPreferences(_ context.Context, arg d
81848190
Disabled: disabled,
81858191
UserID: arg.UserID,
81868192
NotificationTemplateID: templateID,
8187-
CreatedAt: time.Now(),
8188-
UpdatedAt: time.Now(),
8193+
CreatedAt: dbtime.Now(),
8194+
UpdatedAt: dbtime.Now(),
81898195
}
81908196
q.notificationPreferences = append(q.notificationPreferences, np)
81918197
upserted++

coderd/database/migrations/testdata/fixtures/000238_notifications_preferences.up.sql

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
INSERT INTO users(id, email, username, hashed_password, created_at, updated_at, status, rbac_roles, deleted)
2-
VALUES ('fc1511ef-4fcf-4a3b-98a1-8df64160e35a', 'githubuser@coder.com', 'githubuser', '\x',
3-
'2022-11-02 13:05:21.445455+02', '2022-11-02 13:05:21.445455+02', 'active', '{}', false) ON CONFLICT DO NOTHING;
4-
51
INSERT INTO notification_templates (id, name, title_template, body_template, "group")
62
VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'A', 'title', 'body', 'Group 1') ON CONFLICT DO NOTHING;
73

coderd/notifications_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func TestNotificationPreferences(t *testing.T) {
115115
t.Run("Initial state", func(t *testing.T) {
116116
t.Parallel()
117117

118-
ctx := testutil.Context(t, testutil.WaitShort)
118+
ctx := testutil.Context(t, testutil.WaitLong)
119119
api := coderdtest.New(t, createOpts(t))
120120
firstUser := coderdtest.CreateFirstUser(t, api)
121121

@@ -133,7 +133,7 @@ func TestNotificationPreferences(t *testing.T) {
133133
t.Run("Insufficient permissions", func(t *testing.T) {
134134
t.Parallel()
135135

136-
ctx := testutil.Context(t, testutil.WaitShort)
136+
ctx := testutil.Context(t, testutil.WaitLong)
137137
api := coderdtest.New(t, createOpts(t))
138138
firstUser := coderdtest.CreateFirstUser(t, api)
139139

@@ -156,7 +156,7 @@ func TestNotificationPreferences(t *testing.T) {
156156
t.Run("Admin may read any users' preferences", func(t *testing.T) {
157157
t.Parallel()
158158

159-
ctx := testutil.Context(t, testutil.WaitShort)
159+
ctx := testutil.Context(t, testutil.WaitLong)
160160
api := coderdtest.New(t, createOpts(t))
161161
firstUser := coderdtest.CreateFirstUser(t, api)
162162

@@ -174,7 +174,7 @@ func TestNotificationPreferences(t *testing.T) {
174174
t.Run("Admin may update any users' preferences", func(t *testing.T) {
175175
t.Parallel()
176176

177-
ctx := testutil.Context(t, testutil.WaitShort)
177+
ctx := testutil.Context(t, testutil.WaitLong)
178178
api := coderdtest.New(t, createOpts(t))
179179
firstUser := coderdtest.CreateFirstUser(t, api)
180180

@@ -202,7 +202,7 @@ func TestNotificationPreferences(t *testing.T) {
202202
t.Run("Add preferences", func(t *testing.T) {
203203
t.Parallel()
204204

205-
ctx := testutil.Context(t, testutil.WaitShort)
205+
ctx := testutil.Context(t, testutil.WaitLong)
206206
api := coderdtest.New(t, createOpts(t))
207207
firstUser := coderdtest.CreateFirstUser(t, api)
208208

@@ -230,7 +230,7 @@ func TestNotificationPreferences(t *testing.T) {
230230
t.Run("Modify preferences", func(t *testing.T) {
231231
t.Parallel()
232232

233-
ctx := testutil.Context(t, testutil.WaitShort)
233+
ctx := testutil.Context(t, testutil.WaitLong)
234234
api := coderdtest.New(t, createOpts(t))
235235
firstUser := coderdtest.CreateFirstUser(t, api)
236236

0 commit comments

Comments
 (0)