a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package mcp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/zzet/gortex/internal/graph"
|
|
)
|
|
|
|
// TestRouteMethodAndPath_NestedContractMeta guards the fix for the
|
|
// read/write key mismatch: contract nodes carry route fields under the
|
|
// nested contract_meta map, not at the top level where the reader looked.
|
|
func TestRouteMethodAndPath_NestedContractMeta(t *testing.T) {
|
|
http := &graph.Node{Kind: graph.KindContract, Meta: map[string]any{
|
|
"type": "http", "role": "provider",
|
|
"contract_meta": map[string]any{"method": "GET", "path": "/v1/users"},
|
|
}}
|
|
if m, p := routeMethodAndPath(http); m != "GET" || p != "/v1/users" {
|
|
t.Fatalf("nested http: got (%q,%q), want (GET,/v1/users)", m, p)
|
|
}
|
|
|
|
// gRPC service falls through the method/path branch (the existing
|
|
// short-circuit returns method first); a service-only node exercises
|
|
// the service branch reading from the nested map.
|
|
grpc := &graph.Node{Kind: graph.KindContract, Meta: map[string]any{
|
|
"contract_meta": map[string]any{"service": "UserSvc"},
|
|
}}
|
|
if m, p := routeMethodAndPath(grpc); m != "" || p != "UserSvc" {
|
|
t.Fatalf("nested grpc service: got (%q,%q), want (\"\",UserSvc)", m, p)
|
|
}
|
|
|
|
// A node that stamps the fields at the top level still resolves.
|
|
top := &graph.Node{Kind: graph.KindContract, Meta: map[string]any{
|
|
"method": "POST", "path": "/x",
|
|
}}
|
|
if m, p := routeMethodAndPath(top); m != "POST" || p != "/x" {
|
|
t.Fatalf("top-level fallback: got (%q,%q), want (POST,/x)", m, p)
|
|
}
|
|
}
|