Skip to content

Commit c920508

Browse files
committed
Fixing tests
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent a333f98 commit c920508

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

coderd/prometheusmetrics/prometheusmetrics_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,13 @@ func TestWorkspaceDetails(t *testing.T) {
190190
for _, tc := range []struct {
191191
Name string
192192
Database func() database.Store
193-
ExpectedSeries int
194-
ExpectedStatuses map[codersdk.ProvisionerJobStatus]int
195193
ExpectedWorkspaces int
194+
ExpectedStatuses map[codersdk.ProvisionerJobStatus]int
196195
}{{
197196
Name: "None",
198197
Database: func() database.Store {
199198
return dbmem.New()
200199
},
201-
ExpectedSeries: 0,
202200
ExpectedWorkspaces: 0,
203201
}, {
204202
Name: "Multiple",
@@ -214,7 +212,6 @@ func TestWorkspaceDetails(t *testing.T) {
214212
insertRunning(t, db)
215213
return db
216214
},
217-
ExpectedSeries: 7,
218215
ExpectedWorkspaces: 7,
219216
ExpectedStatuses: map[codersdk.ProvisionerJobStatus]int{
220217
codersdk.ProvisionerJobCanceled: 1,
@@ -234,10 +231,10 @@ func TestWorkspaceDetails(t *testing.T) {
234231
require.Eventually(t, func() bool {
235232
metrics, err := registry.Gather()
236233
assert.NoError(t, err)
234+
237235
stMap := map[codersdk.ProvisionerJobStatus]int{}
238-
wMap := map[string]struct{}{}
239236
for _, m := range metrics {
240-
if m.GetName() != "coderd_api_workspace_detail" {
237+
if m.GetName() != "coderd_workspace_latest_build_status" {
241238
continue
242239
}
243240

@@ -247,12 +244,9 @@ func TestWorkspaceDetails(t *testing.T) {
247244
continue
248245
}
249246

250-
switch l.GetName() {
251-
case "status":
247+
if l.GetName() == "status" {
252248
status := codersdk.ProvisionerJobStatus(l.GetValue())
253249
stMap[status] += int(metric.Gauge.GetValue())
254-
case "workspace_name":
255-
wMap[l.GetValue()] = struct{}{}
256250
}
257251
}
258252
}
@@ -267,9 +261,8 @@ func TestWorkspaceDetails(t *testing.T) {
267261
stSum += count
268262
}
269263

270-
t.Logf("status series = %d, expected == %d", stSum, tc.ExpectedSeries)
271-
t.Logf("workspace series = %d, expected == %d", len(wMap), tc.ExpectedWorkspaces)
272-
return stSum == tc.ExpectedSeries && len(wMap) == tc.ExpectedWorkspaces
264+
t.Logf("status series = %d, expected == %d", stSum, tc.ExpectedWorkspaces)
265+
return stSum == tc.ExpectedWorkspaces
273266
}, testutil.WaitShort, testutil.IntervalFast)
274267
})
275268
}

0 commit comments

Comments
 (0)