mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
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:
@ -2,6 +2,7 @@ package coderd_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@ -1736,7 +1737,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
JobID: build.JobID,
|
||||
})
|
||||
agent := dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{
|
||||
ResourceID: resource.ID,
|
||||
ResourceID: resource.ID,
|
||||
FirstConnectedAt: sql.NullTime{Valid: true, Time: dbtime.Now().Add(-time.Hour)},
|
||||
})
|
||||
|
||||
// When: fetching timings for the build
|
||||
@ -1767,7 +1769,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
agents := make([]database.WorkspaceAgent, 5)
|
||||
for i := range agents {
|
||||
agents[i] = dbgen.WorkspaceAgent(t, db, database.WorkspaceAgent{
|
||||
ResourceID: resource.ID,
|
||||
ResourceID: resource.ID,
|
||||
FirstConnectedAt: sql.NullTime{Valid: true, Time: dbtime.Now().Add(-time.Duration(i) * time.Hour)},
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user