diff --git a/agent/agentcontainers/api_test.go b/agent/agentcontainers/api_test.go index faf91d06ae..777f8c78c2 100644 --- a/agent/agentcontainers/api_test.go +++ b/agent/agentcontainers/api_test.go @@ -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()