Skip to content

Commit 9908c84

Browse files
authored
test: Return early and avoid using nil handler (#7411)
* test: Return early and avoid using nil handler
1 parent b4d913e commit 9908c84

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

enterprise/coderd/coderdenttest/proxytest.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ func NewWorkspaceProxy(t *testing.T, coderdAPI *coderd.API, owner *codersdk.Clie
4747
options = &ProxyOptions{}
4848
}
4949

50-
// HTTP Server
50+
// HTTP Server. We have to start this once to get the access URL to start
51+
// the workspace proxy with. The workspace proxy has the handler, so the
52+
// http server will start with a 503 until the proxy is started.
5153
var mutex sync.RWMutex
5254
var handler http.Handler
5355
srv := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
5456
mutex.RLock()
5557
defer mutex.RUnlock()
5658
if handler == nil {
5759
http.Error(w, "handler not set", http.StatusServiceUnavailable)
60+
return
5861
}
5962

6063
handler.ServeHTTP(w, r)

0 commit comments

Comments
 (0)