feat: migrate to typed messages
- 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:
26
e2e_test.go
26
e2e_test.go
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user