feat: migrate to typed messages
Some checks failed
CI / Lint (pull_request) Failing after 57s
CI / Test (pull_request) Failing after 1m23s
CI / Release (pull_request) Has been skipped
CI / Docker Build & Push (pull_request) Has been skipped
CI / Notify (pull_request) Successful in 1s

- Switch OnMessage → OnTypedMessage with natsutil.Decode[messages.PipelineTrigger]
- Return *messages.PipelineStatus (not map[string]any)
- Remove strVal/mapVal helpers
- Add .dockerignore, GOAMD64=v3 in Dockerfile
- Update tests for typed structs (14 tests pass)
This commit is contained in:
2026-02-20 07:11:03 -05:00
parent 8f9b2203ca
commit 7cdcbfbff3
5 changed files with 97 additions and 75 deletions

View File

@@ -6,6 +6,8 @@ import (
"net/http/httptest"
"sync/atomic"
"testing"
"git.daviestechlabs.io/daviestechlabs/handler-base/messages"
)
// ────────────────────────────────────────────────────────────────────────────
@@ -117,34 +119,28 @@ func TestPipelineDispatchE2E_AllEngines(t *testing.T) {
}
func TestPipelineDispatchE2E_UnknownPipeline(t *testing.T) {
// Simulate what main.go's OnMessage does for unknown pipeline
data := map[string]any{
"request_id": "req-bad",
"pipeline": "nonexistent-pipeline",
}
pipelineName := strVal(data, "pipeline", "")
// Verify unknown pipeline is rejected and available list is provided
pipelineName := "nonexistent-pipeline"
_, ok := pipelines[pipelineName]
if ok {
t.Error("nonexistent pipeline should not be found")
}
// Build error response like main.go
names := make([]string, 0, len(pipelines))
for k := range pipelines {
names = append(names, k)
}
resp := map[string]any{
"request_id": strVal(data, "request_id", ""),
"status": "error",
"error": "Unknown pipeline: nonexistent-pipeline",
"available_pipelines": names,
resp := &messages.PipelineStatus{
RequestID: "req-bad",
Status: "error",
Error: "Unknown pipeline: nonexistent-pipeline",
AvailablePipelines: names,
}
if resp["status"] != "error" {
if resp.Status != "error" {
t.Error("expected error status")
}
if len(resp["available_pipelines"].([]string)) != len(pipelines) {
if len(resp.AvailablePipelines) != len(pipelines) {
t.Errorf("available_pipelines count mismatch")
}
}