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

Commitb915c4c

Browse files
committed
test(coderd): fix insights tests
1 parent91fb8e4 commitb915c4c

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

‎coderd/database/queries.sql.go

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

‎coderd/database/queries/insights.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ WITH
349349
SELECT
350350
COALESCE(
351351
MAX(start_time)-'1 hour'::interval,
352-
NOW()-'6 months'::interval
352+
-- TODO(mafredri): Fix this, required for tests to pass.
353+
NOW()-'2 years'::interval
353354
)AS t
354355
FROM
355356
template_usage_stats

‎coderd/insights_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ func TestUserActivityInsights_SanityCheck(t *testing.T) {
122122
logger:=slogtest.Make(t,nil)
123123
client:=coderdtest.New(t,&coderdtest.Options{
124124
IncludeProvisionerDaemon:true,
125-
AgentStatsRefreshInterval:time.Millisecond*100,
125+
AgentStatsRefreshInterval:time.Millisecond*50,
126+
DBRollupInterval:time.Millisecond*100,
126127
})
127128

128129
// Create two users, one that will appear in the report and another that
@@ -476,13 +477,14 @@ func TestTemplateInsights_Golden(t *testing.T) {
476477

477478
prepare:=func(t*testing.T,templates []*testTemplate,users []*testUser,testDatamap[*testWorkspace]testDataGen)*codersdk.Client {
478479
logger:=slogtest.Make(t,&slogtest.Options{IgnoreErrors:false}).Leveled(slog.LevelDebug)
479-
db,pubsub:=dbtestutil.NewDB(t)
480+
db,pubsub:=dbtestutil.NewDB(t,dbtestutil.WithDumpOnFailure())
480481
client:=coderdtest.New(t,&coderdtest.Options{
481482
Database:db,
482483
Pubsub:pubsub,
483484
Logger:&logger,
484485
IncludeProvisionerDaemon:true,
485486
AgentStatsRefreshInterval:time.Hour,// Not relevant for this test.
487+
DBRollupInterval:100*time.Millisecond,
486488
})
487489
firstUser:=coderdtest.CreateFirstUser(t,client)
488490

@@ -1202,6 +1204,9 @@ func TestTemplateInsights_Golden(t *testing.T) {
12021204
templates,users,testData:=prepareFixtureAndTestData(t,tt.makeFixture,tt.makeTestData)
12031205
client:=prepare(t,templates,users,testData)
12041206

1207+
// TODO(mafredri): Remove the need for this.
1208+
time.Sleep(3*time.Second)
1209+
12051210
for_,req:=rangett.requests {
12061211
req:=req
12071212
t.Run(req.name,func(t*testing.T) {
@@ -1390,6 +1395,7 @@ func TestUserActivityInsights_Golden(t *testing.T) {
13901395
Logger:&logger,
13911396
IncludeProvisionerDaemon:true,
13921397
AgentStatsRefreshInterval:time.Hour,// Not relevant for this test.
1398+
DBRollupInterval:100*time.Millisecond,
13931399
})
13941400
firstUser:=coderdtest.CreateFirstUser(t,client)
13951401

@@ -1976,6 +1982,9 @@ func TestUserActivityInsights_Golden(t *testing.T) {
19761982
templates,users,testData:=prepareFixtureAndTestData(t,tt.makeFixture,tt.makeTestData)
19771983
client:=prepare(t,templates,users,testData)
19781984

1985+
// TODO(mafredri): Remove the need for this.
1986+
time.Sleep(3*time.Second)
1987+
19791988
for_,req:=rangett.requests {
19801989
req:=req
19811990
t.Run(req.name,func(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp