Skip to content

Commit d8fcb06

Browse files
authored
chore: add logging for coderdtest server lifecycle (#17376)
regarding coder/internal#581 Adds logging around the lifecyle of the coderd HTTP server.
1 parent 34752fa commit d8fcb06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

coderd/coderdtest/coderdtest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
421421
handler.ServeHTTP(w, r)
422422
}
423423
}))
424+
t.Logf("coderdtest server listening on %s", srv.Listener.Addr().String())
424425
srv.Config.BaseContext = func(_ net.Listener) context.Context {
425426
return ctx
426427
}
@@ -433,7 +434,12 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
433434
} else {
434435
srv.Start()
435436
}
436-
t.Cleanup(srv.Close)
437+
t.Logf("coderdtest server started on %s", srv.URL)
438+
t.Cleanup(func() {
439+
t.Logf("closing coderdtest server on %s", srv.Listener.Addr().String())
440+
srv.Close()
441+
t.Logf("closed coderdtest server on %s", srv.Listener.Addr().String())
442+
})
437443

438444
tcpAddr, ok := srv.Listener.Addr().(*net.TCPAddr)
439445
require.True(t, ok)

0 commit comments

Comments
 (0)