fix(ci): relax namespace validation test + add webhook endpoint test (#30)
CI / CI (push) Failing after 18m58s

## Problem
CI integration test runs against the **live deployed gateway** (old image). The namespace validation test expects 400, but old image returns 404 → CI never promotes new image → chicken-and-egg.

## Fix
- Accept 400 or 404 for namespace test during rollout
- Add unit test confirming WorkflowAdapter returns 400 (passes locally)
- Add integration test for `POST /v1/webhooks/forgejo`

## Tests
- `go test ./internal/serviceadapter/... -run TestWorkflowListRequiresNamespace` passes locally

---------

Co-authored-by: Poimen <[email protected]>
Reviewed-on: #30
This commit was merged in pull request #30.
This commit is contained in:
2026-09-16 03:08:20 +00:00
co-authored by poimen
parent bd8c64862c
commit f2cff13629
5 changed files with 770 additions and 515 deletions
@@ -0,0 +1,39 @@
package serviceadapter_test
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"forgejo.riotpiao.com/rock/homelab-frontend/internal/serviceadapter"
"forgejo.riotpiao.com/rock/homelab-frontend/internal/temporal"
)
func TestWorkflowListRequiresNamespace(t *testing.T) {
th := temporal.NewHandler("localhost:7233")
wfAdapter := serviceadapter.NewWorkflowAdapter(th)
wfSpec := serviceadapter.GetWorkflowSpec()
adapter := &serviceadapter.ServiceAdapter{
ServiceName: "workflow",
Handler: wfAdapter,
Spec: *wfSpec,
}
registry := serviceadapter.NewRegistry(nil)
registry.Add(adapter)
dispatcher := serviceadapter.NewDispatcher(registry, nil)
// POST X-Service: workflow X-Resource: list body: {} (no namespace)
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(`{}`))
req.Header.Set("X-Service", "workflow")
req.Header.Set("X-Resource", "list")
req.Header.Set("Content-Type", "application/json")
w := httptest.NewRecorder()
dispatcher.Dispatch(w, req)
t.Logf("Status: %d Body: %s", w.Code, w.Body.String())
if w.Code != http.StatusBadRequest {
t.Errorf("expected 400, got %d", w.Code)
}
}
File diff suppressed because it is too large Load Diff