mirror of
https://github.com/coder/coder.git
synced 2026-09-22 13:10:21 +08:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user