From 54d2152dc33dbcbc1f39e08166db219701c333a4 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 9 Apr 2025 15:05:57 +0400 Subject: [PATCH] fix: fix http cache dir creation order in coderdtest --- coderd/coderdtest/coderdtest.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index b9097863a5f67..0f0a99807a37d 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -405,6 +405,12 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can workspacestats.TrackerWithTickFlush(options.WorkspaceUsageTrackerTick, options.WorkspaceUsageTrackerFlush), ) + // create the TempDir for the HTTP file cache BEFORE we start the server and set a t.Cleanup to close it. TempDir() + // registers a Cleanup function that deletes the directory, and Cleanup functions are called in reverse order. If + // we don't do this, then we could try to delete the directory before the HTTP server is done with all files in it, + // which on Windows will fail (can't delete files until all programs have closed handles to them). + cacheDir := t.TempDir() + var mutex sync.RWMutex var handler http.Handler srv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -515,7 +521,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can AppHostname: options.AppHostname, AppHostnameRegex: appHostnameRegex, Logger: *options.Logger, - CacheDir: t.TempDir(), + CacheDir: cacheDir, RuntimeConfig: runtimeManager, Database: options.Database, Pubsub: options.Pubsub, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy