Wait for webhook deployments in handlers tests instead of sleeping (closes #211)
Check / check (pull_request) Skipped
Check / check (pull_request) Skipped
TestHandleWebhookProcessesValidWebhook slept 100ms after posting a webhook, racing the background deployment that writes its log under the test's temp directory against temp directory cleanup. The test context now keeps the webhook service, and the test waits on its WaitForDeployments, as the webhook service tests already do. The other webhook handler tests never start a deployment. Model: opus-5-5
This commit is contained in:
@@ -20,6 +20,9 @@ regress.
|
|||||||
|
|
||||||
# Completed Steps
|
# Completed Steps
|
||||||
|
|
||||||
|
- 2026-09-23: Fixed the same `t.TempDir` cleanup race in `internal/handlers`:
|
||||||
|
`TestHandleWebhookProcessesValidWebhook` now waits with the webhook service's
|
||||||
|
`WaitForDeployments` instead of sleeping (#211).
|
||||||
- 2026-09-22: Vendored the canonical prettier/format toolchain from the
|
- 2026-09-22: Vendored the canonical prettier/format toolchain from the
|
||||||
`sneak/prompts` scaffold: added `.prettierrc` (tabWidth 4, proseWrap always),
|
`sneak/prompts` scaffold: added `.prettierrc` (tabWidth 4, proseWrap always),
|
||||||
pinned `package.json` + `yarn.lock` (prettier 3.8.1), taught
|
pinned `package.json` + `yarn.lock` (prettier 3.8.1), taught
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -43,6 +42,7 @@ type testContext struct {
|
|||||||
authSvc *auth.Service
|
authSvc *auth.Service
|
||||||
appSvc *app.Service
|
appSvc *app.Service
|
||||||
deploySvc *deploy.Service
|
deploySvc *deploy.Service
|
||||||
|
webhookSvc *webhook.Service
|
||||||
middleware *middleware.Middleware
|
middleware *middleware.Middleware
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,6 +188,7 @@ func setupTestHandlers(t *testing.T) *testContext {
|
|||||||
authSvc: authSvc,
|
authSvc: authSvc,
|
||||||
appSvc: appSvc,
|
appSvc: appSvc,
|
||||||
deploySvc: deploySvc,
|
deploySvc: deploySvc,
|
||||||
|
webhookSvc: webhookSvc,
|
||||||
middleware: mw,
|
middleware: mw,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1213,8 +1214,7 @@ func TestHandleWebhookProcessesValidWebhook(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, http.StatusOK, recorder.Code)
|
assert.Equal(t, http.StatusOK, recorder.Code)
|
||||||
|
|
||||||
// Allow async deployment goroutine to complete before test cleanup.
|
// Wait for the async deployment goroutine to finish so its writes
|
||||||
// The deployment will fail quickly (docker not connected) but we need
|
// under the temp dir complete before test cleanup.
|
||||||
// to wait for it to finish to avoid temp directory cleanup race.
|
testCtx.webhookSvc.WaitForDeployments()
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user