Pulse/internal/api/diagnostics_contract_test.go
rcourtman ee8a24e14a backend and governance: MCP contract, agent capabilities, API, and release-control
Manifest-backed MCP tools, prompts, and resources with surface affordance contracts; agent capability manifest and governance projection; API contract tests and capability route projection; operations-loop and intelligence-funnel telemetry; release-control subsystem documentation, registry, and tooling; licensing and configuration.
2026-06-23 17:26:15 +01:00

56 lines
1.4 KiB
Go

package api
import (
"encoding/json"
"strings"
"testing"
)
func TestContract_DiagnosticsInfoExcludesInternalAnalytics(t *testing.T) {
payload := EmptyDiagnosticsInfo()
got, err := json.Marshal(payload.NormalizeCollections())
if err != nil {
t.Fatalf("marshal diagnostics info: %v", err)
}
for _, forbidden := range []string{
"commercialFunnel",
"infrastructureOnboarding",
"pricing_viewed",
"credentials_opened",
} {
if strings.Contains(string(got), forbidden) {
t.Fatalf("diagnostics contract leaked internal analytics field %q: %s", forbidden, got)
}
}
}
func TestContract_AssistantDiagnosticsUseNativeRuntimeVocabulary(t *testing.T) {
payload := EmptyDiagnosticsInfo()
payload.AIChat = &AIChatDiagnostic{
Enabled: true,
Running: true,
Healthy: true,
Model: "ollama:llama3",
AssistantRuntimeConnected: true,
}
got, err := json.Marshal(payload.NormalizeCollections())
if err != nil {
t.Fatalf("marshal diagnostics info: %v", err)
}
body := string(got)
if !strings.Contains(body, `"assistantRuntimeConnected":true`) {
t.Fatalf("diagnostics payload must expose native Assistant runtime connectivity: %s", body)
}
for _, forbidden := range []string{
"mcpConnected",
"mcpToolCount",
} {
if strings.Contains(body, forbidden) {
t.Fatalf("diagnostics payload must not expose legacy MCP diagnostic field %q: %s", forbidden, body)
}
}
}