@@ -61,7 +61,6 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
61
61
62
62
cache , db := newMetricsCache (t , log , clock , metricscache.Intervals {
63
63
TemplateBuildTimes : time .Minute ,
64
- DeploymentStats : time .Minute ,
65
64
}, false )
66
65
67
66
org := dbgen .Organization (t , db , database.Organization {})
@@ -77,10 +76,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
77
76
trapTickerFunc .MustWait (ctx ).MustRelease (ctx )
78
77
trapTickerFunc .MustWait (ctx ).MustRelease (ctx )
79
78
80
- _ , wait := clock .AdvanceNext ()
81
- wait .MustWait (ctx )
82
- _ , wait = clock .AdvanceNext ()
83
- wait .MustWait (ctx )
79
+ clock .Advance (time .Minute ).MustWait (ctx )
84
80
85
81
count , ok := cache .TemplateWorkspaceOwners (template .ID )
86
82
require .True (t , ok , "TemplateWorkspaceOwners should be populated" )
@@ -92,10 +88,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
92
88
OwnerID : user1 .ID ,
93
89
})
94
90
95
- _ , wait = clock .AdvanceNext ()
96
- wait .MustWait (ctx )
97
- _ , wait = clock .AdvanceNext ()
98
- wait .MustWait (ctx )
91
+ clock .Advance (time .Minute ).MustWait (ctx )
99
92
100
93
count , _ = cache .TemplateWorkspaceOwners (template .ID )
101
94
require .Equal (t , 1 , count , "should have 1 owner after adding workspace" )
@@ -106,10 +99,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
106
99
OwnerID : user2 .ID ,
107
100
})
108
101
109
- _ , wait = clock .AdvanceNext ()
110
- wait .MustWait (ctx )
111
- _ , wait = clock .AdvanceNext ()
112
- wait .MustWait (ctx )
102
+ clock .Advance (time .Minute ).MustWait (ctx )
113
103
114
104
count , _ = cache .TemplateWorkspaceOwners (template .ID )
115
105
require .Equal (t , 2 , count , "should have 2 owners after adding second workspace" )
@@ -126,10 +116,7 @@ func TestCache_TemplateWorkspaceOwners(t *testing.T) {
126
116
Deleted : true ,
127
117
})
128
118
129
- _ , wait = clock .AdvanceNext ()
130
- wait .MustWait (ctx )
131
- _ , wait = clock .AdvanceNext ()
132
- wait .MustWait (ctx )
119
+ clock .Advance (time .Minute ).MustWait (ctx )
133
120
134
121
count , _ = cache .TemplateWorkspaceOwners (template .ID )
135
122
require .Equal (t , 1 , count , "should have 1 owner after deleting workspace" )
@@ -233,7 +220,6 @@ func TestCache_BuildTime(t *testing.T) {
233
220
defer trapTickerFunc .Close ()
234
221
cache , db := newMetricsCache (t , log , clock , metricscache.Intervals {
235
222
TemplateBuildTimes : time .Minute ,
236
- DeploymentStats : time .Minute ,
237
223
}, false )
238
224
239
225
org := dbgen .Organization (t , db , database.Organization {})
@@ -282,10 +268,7 @@ func TestCache_BuildTime(t *testing.T) {
282
268
trapTickerFunc .MustWait (ctx ).MustRelease (ctx )
283
269
trapTickerFunc .MustWait (ctx ).MustRelease (ctx )
284
270
285
- _ , wait := clock .AdvanceNext ()
286
- wait .MustWait (ctx )
287
- _ , wait = clock .AdvanceNext ()
288
- wait .MustWait (ctx )
271
+ clock .Advance (time .Minute ).MustWait (ctx )
289
272
290
273
if tt .want .loads {
291
274
wantTransition := codersdk .WorkspaceTransition (tt .args .transition )
@@ -322,8 +305,7 @@ func TestCache_DeploymentStats(t *testing.T) {
322
305
defer tickerTrap .Close ()
323
306
324
307
cache , db := newMetricsCache (t , log , clock , metricscache.Intervals {
325
- TemplateBuildTimes : time .Minute ,
326
- DeploymentStats : time .Minute ,
308
+ DeploymentStats : time .Minute ,
327
309
}, false )
328
310
329
311
err := db .InsertWorkspaceAgentStats (context .Background (), database.InsertWorkspaceAgentStatsParams {
@@ -353,10 +335,7 @@ func TestCache_DeploymentStats(t *testing.T) {
353
335
tickerTrap .MustWait (ctx ).MustRelease (ctx )
354
336
tickerTrap .MustWait (ctx ).MustRelease (ctx )
355
337
356
- _ , wait := clock .AdvanceNext ()
357
- wait .MustWait (ctx )
358
- _ , wait = clock .AdvanceNext ()
359
- wait .MustWait (ctx )
338
+ clock .Advance (time .Minute ).MustWait (ctx )
360
339
361
340
stat , ok := cache .DeploymentStats ()
362
341
require .True (t , ok , "cache should be populated after refresh" )
0 commit comments