mirror of
https://github.com/coder/coder.git
synced 2026-09-22 05:05:20 +08:00
fix(coderd): improve workspace tests (#15069)
With [a recent PR](https://github.com/coder/coder/pull/14923) we introduced [new tests](https://github.com/coder/coder/pull/14923/files#diff-81081239b93aaa61eb8d180a5f9870fda8f0ab5cb4c6727d9d1636aa933e597b) that - while running in parallel to the existing ones - are failing. This PR is a quick proposal to fix it - tested in local and in the CI to unblock the situation. We can ignore it to work on a longer term solution if preferred.
This commit is contained in:
@@ -1183,9 +1183,8 @@ func TestPostWorkspaceBuild(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
//nolint:paralleltest
|
||||
func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Setup the test environment with a template and version
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
client := coderdtest.New(t, &coderdtest.Options{
|
||||
@@ -1238,9 +1237,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
//nolint:paralleltest
|
||||
t.Run("NonExistentBuild", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching an inexistent build
|
||||
buildID := uuid.New()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
@@ -1252,9 +1250,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
require.Contains(t, err.Error(), "not found")
|
||||
})
|
||||
|
||||
//nolint:paralleltest
|
||||
t.Run("EmptyTimings", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching timings for a build with no timings
|
||||
build := makeBuild()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
@@ -1267,9 +1264,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
require.Empty(t, res.AgentScriptTimings)
|
||||
})
|
||||
|
||||
//nolint:paralleltest
|
||||
t.Run("ProvisionerTimings", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching timings for a build with provisioner timings
|
||||
build := makeBuild()
|
||||
provisionerTimings := dbgen.ProvisionerJobTimings(t, db, build, 5)
|
||||
@@ -1294,9 +1290,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
//nolint:paralleltest
|
||||
t.Run("AgentScriptTimings", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching timings for a build with agent script timings
|
||||
build := makeBuild()
|
||||
resource := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
|
||||
@@ -1328,9 +1323,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
//nolint:paralleltest
|
||||
t.Run("NoAgentScripts", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching timings for a build with no agent scripts
|
||||
build := makeBuild()
|
||||
resource := dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
|
||||
@@ -1349,9 +1343,8 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
})
|
||||
|
||||
// Some workspaces might not have agents. It is improbable, but possible.
|
||||
//nolint:paralleltest
|
||||
t.Run("NoAgents", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// When: fetching timings for a build with no agents
|
||||
build := makeBuild()
|
||||
dbgen.WorkspaceResource(t, db, database.WorkspaceResource{
|
||||
@@ -1359,6 +1352,7 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
})
|
||||
|
||||
// Then: return a response with empty agent script timings
|
||||
// trigger build
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
t.Cleanup(cancel)
|
||||
res, err := client.WorkspaceBuildTimings(ctx, build.ID)
|
||||
|
||||
Reference in New Issue
Block a user