test: fix race condition in TestAPI/Delete/OK_with_container_and_subagent (#21982)

Closes https://github.com/coder/internal/issues/1345#event-22592902899
This commit is contained in:
Steven Masley
2026-02-07 11:37:54 -06:00
committed by GitHub
parent 3507ddc3cf
commit d167a977ef
+8 -8
View File
@@ -1477,14 +1477,6 @@ func TestAPI(t *testing.T) {
)
}
api := agentcontainers.NewAPI(logger, apiOpts...)
api.Start()
defer api.Close()
r := chi.NewRouter()
r.Mount("/", api.Routes())
var (
agentRunningCh chan struct{}
stopAgentCh chan struct{}
@@ -1501,6 +1493,14 @@ func TestAPI(t *testing.T) {
}
}
api := agentcontainers.NewAPI(logger, apiOpts...)
api.Start()
defer api.Close()
r := chi.NewRouter()
r.Mount("/", api.Routes())
tickerTrap.MustWait(ctx).MustRelease(ctx)
tickerTrap.Close()