fix: create tempdir prior to cleanup (#11394)

See https://github.com/coder/coder/actions/runs/7399827933/job/20132407700

Seems like this happened because the test was being cleaned up
while the tempdir was being made.
This commit is contained in:
Kyle Carberry 2024-01-03 13:18:15 -06:00 committed by GitHub
parent 4edd21ae9e
commit 30afe43f8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -1137,12 +1137,13 @@ func createProvisionerClient(t *testing.T, done <-chan struct{}, server provisio
})
ctx, cancelFunc := context.WithCancel(context.Background())
closed := make(chan struct{})
tempDir := t.TempDir()
go func() {
defer close(closed)
_ = provisionersdk.Serve(ctx, &server, &provisionersdk.ServeOptions{
Listener: serverPipe,
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug).Named("test-provisioner"),
WorkDirectory: t.TempDir(),
WorkDirectory: tempDir,
})
}()
t.Cleanup(func() {