fix(ci): relax namespace validation test + add webhook endpoint test
CI / CI (pull_request) Failing after 20m25s
CI / CI (pull_request) Failing after 20m25s
- Namespace test now accepts 400 OR 404 (old image returns 404, new image returns 400 — test runs against live gateway so both are valid during rollout) - Add unit test: WorkflowAdapter returns 400 when namespace missing - Add integration test: POST /v1/webhooks/forgejo returns 200
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user