fix(coderd): ensure agent timings are non-zero on insert (#18065)

Relates to https://github.com/coder/coder/issues/15432

Ensures that no workspace build timings with zero values for started_at or ended_at are inserted into the DB or returned from the API.
This commit is contained in:
Cian Johnston
2025-05-29 13:36:06 +01:00
committed by GitHub
parent 5f34d01906
commit 776c144128
8 changed files with 217 additions and 25 deletions
+6
View File
@@ -144,6 +144,12 @@ func TestScriptReportsTiming(t *testing.T) {
timing := timings[0]
require.Equal(t, int32(0), timing.ExitCode)
if assert.True(t, timing.Start.IsValid(), "start time should be valid") {
require.NotZero(t, timing.Start.AsTime(), "start time should not be zero")
}
if assert.True(t, timing.End.IsValid(), "end time should be valid") {
require.NotZero(t, timing.End.AsTime(), "end time should not be zero")
}
require.GreaterOrEqual(t, timing.End.AsTime(), timing.Start.AsTime())
}