mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
test(coderd): close metricscache and avoid background context (#7996)
This commit is contained in:
committed by
GitHub
parent
2e7e99b135
commit
51226c55ab
@ -169,6 +169,8 @@ func newWithCloser(t testing.TB, options *Options) (*codersdk.Client, io.Closer)
|
||||
}
|
||||
|
||||
func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.CancelFunc, *url.URL, *coderd.Options) {
|
||||
t.Helper()
|
||||
|
||||
if options == nil {
|
||||
options = &Options{}
|
||||
}
|
||||
@ -402,6 +404,8 @@ func NewWithAPI(t testing.TB, options *Options) (*codersdk.Client, io.Closer, *c
|
||||
// well with coderd testing. It registers the "echo" provisioner for
|
||||
// quick testing.
|
||||
func NewProvisionerDaemon(t testing.TB, coderAPI *coderd.API) io.Closer {
|
||||
t.Helper()
|
||||
|
||||
echoClient, echoServer := provisionersdk.MemTransportPipe()
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
t.Cleanup(func() {
|
||||
|
@ -435,6 +435,7 @@ func TestCache_DeploymentStats(t *testing.T) {
|
||||
cache := metricscache.New(db, slogtest.Make(t, nil), metricscache.Intervals{
|
||||
DeploymentStats: testutil.IntervalFast,
|
||||
})
|
||||
defer cache.Close()
|
||||
|
||||
_, err := db.InsertWorkspaceAgentStat(context.Background(), database.InsertWorkspaceAgentStatParams{
|
||||
ID: uuid.New(),
|
||||
|
@ -347,7 +347,7 @@ func createWorkspaceWithApps(t *testing.T, client *codersdk.Client, orgID uuid.U
|
||||
primaryAppHost, err := client.AppHost(appHostCtx)
|
||||
require.NoError(t, err)
|
||||
if primaryAppHost.Host != "" {
|
||||
manifest, err := agentClient.Manifest(context.Background())
|
||||
manifest, err := agentClient.Manifest(appHostCtx)
|
||||
require.NoError(t, err)
|
||||
proxyURL := fmt.Sprintf(
|
||||
"http://{{port}}--%s--%s--%s%s",
|
||||
|
Reference in New Issue
Block a user