From d77aa3bca3cf7c8186f8208128db3ed85ef16522 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Tue, 21 Jul 2026 13:16:26 -0500 Subject: [PATCH] test(coderd): make TestTemplateVersionDryRun/ImportNotFinished deterministic (#27386) Closes PLAT-334 / [coder/internal#1221](https://github.com/coder/internal/issues/1221). The subtest asserts HTTP 425 while the import job is unfinished, but it ran a real provisioner daemon. Any failure in an early import phase (init, parse, update job) sets `CompletedAt`, which is all `postTemplateVersionDryRun` checks, so the endpoint could return 201 and flake. Run the subtest without a provisioner daemon: the job is never acquired, stays pending, and the 425 is deterministic. > Generated by Coder Agents on behalf of @Emyrk. --- coderd/templateversions_test.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/coderd/templateversions_test.go b/coderd/templateversions_test.go index 9f5e494464..d057787655 100644 --- a/coderd/templateversions_test.go +++ b/coderd/templateversions_test.go @@ -1538,17 +1538,12 @@ func TestTemplateVersionDryRun(t *testing.T) { t.Run("ImportNotFinished", func(t *testing.T) { t.Parallel() - client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) + // No provisioner daemon is running, so the import job is never + // acquired and stays pending. This guarantees the job can neither + // complete nor fail before the dry-run request below. + client := coderdtest.New(t, nil) user := coderdtest.CreateFirstUser(t, client) - // This import job will never finish - version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{ - Parse: echo.ParseComplete, - ProvisionPlan: []*proto.Response{{ - Type: &proto.Response_Log{ - Log: &proto.Log{}, - }, - }}, - }) + version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) defer cancel()