Skip to content

Commit c352822

Browse files
committed
WIP: tests
1 parent 87d40cb commit c352822

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,7 @@ func (s *MethodTestSuite) TestSystemFunctions() {
27142714
}))
27152715
s.Run("DeleteOldReportGeneratorLogs", s.Subtest(func(db database.Store, check *expects) {
27162716
check.Args(database.DeleteOldReportGeneratorLogsParams{
2717-
FrequencyDays: 1,
2717+
Before: dbtime.Now(),
27182718
NotificationTemplateID: uuid.New(),
27192719
}).Asserts(rbac.ResourceSystem, policy.ActionDelete)
27202720
}))

coderd/notifications/reports/generator_internal_test.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
package reports
22

3-
import "testing"
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/prometheus/client_golang/prometheus"
8+
"github.com/stretchr/testify/require"
9+
10+
"cdr.dev/slog/sloggers/slogtest"
11+
"github.com/coder/coder/v2/coderd/coderdtest"
12+
"github.com/coder/coder/v2/coderd/database/dbauthz"
13+
"github.com/coder/coder/v2/coderd/database/dbtestutil"
14+
"github.com/coder/coder/v2/coderd/rbac"
15+
"github.com/coder/coder/v2/testutil"
16+
"github.com/coder/quartz"
17+
)
418

519
func TestReportFailedWorkspaceBuilds(t *testing.T) {
620
t.Parallel()
721

822
t.Run("FailedBuilds_TemplateAdminOptIn_FirstRun_Report_SecondRunTooEarly_NoReport_ThirdRun_Report", func(t *testing.T) {
923
t.Parallel()
24+
25+
// Prepare dependencies
26+
logger := slogtest.Make(t, &slogtest.Options{})
27+
rdb, _ := dbtestutil.NewDB(t)
28+
db := dbauthz.New(rdb, rbac.NewAuthorizer(prometheus.NewRegistry()), logger, coderdtest.AccessControlStorePointer())
29+
notifyEnq := &testutil.FakeNotificationsEnqueuer{}
30+
clk := quartz.NewMock(t)
31+
32+
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
33+
defer cancel()
34+
35+
// Given
36+
37+
// When
38+
err := reportFailedWorkspaceBuilds(ctx, logger, db, notifyEnq, clk)
39+
require.NoError(t, err)
40+
41+
// Then
42+
1043
// TODO
1144
})
1245

0 commit comments

Comments
 (0)