feat(platform): add source readiness operations view

This commit is contained in:
lingniu
2026-07-04 23:29:31 +08:00
parent bf106a9730
commit 44c7748958
9 changed files with 536 additions and 4 deletions

View File

@@ -939,6 +939,44 @@ func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
}
}
func TestHandlerSourceReadiness(t *testing.T) {
handler := NewHandler(NewServiceWithRuntime(NewMockStore(), RuntimeInfo{PlatformRelease: "platform-source-test"}))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/ops/source-readiness", nil)
handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
}
var body struct {
Data SourceReadinessPlan `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatalf("response JSON should decode source readiness: %v body=%s", err, rec.Body.String())
}
if body.Data.PlatformRelease != "platform-source-test" {
t.Fatalf("source readiness should expose runtime release, got %+v", body.Data)
}
if len(body.Data.Sources) < len(canonicalVehicleProtocols) {
t.Fatalf("source readiness should expose canonical protocol slots, got %+v", body.Data.Sources)
}
byProtocol := map[string]SourceReadinessRow{}
for _, source := range body.Data.Sources {
byProtocol[source.Protocol] = source
}
for _, protocol := range canonicalVehicleProtocols {
row, ok := byProtocol[protocol]
if !ok {
t.Fatalf("source readiness missing protocol %s: %+v", protocol, body.Data.Sources)
}
if row.Role == "" || row.Evidence == "" || row.Action == "" || row.Acceptance == "" {
t.Fatalf("source readiness row should be operationally actionable: %+v", row)
}
if !strings.Contains(row.VehiclesHash, "missingProtocol="+protocol) || !strings.Contains(row.RealtimeHash, "protocol="+protocol) {
t.Fatalf("source readiness should include workflow hashes, got %+v", row)
}
}
}
func TestHandlerVehicleDataAPIsResolveVehicleKeyword(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
cases := []struct {