-
Notifications
You must be signed in to change notification settings - Fork 253
Closed
Labels
Description
Objective
Add comprehensive test to ensure generated schemas can validate actual output data (round-trip validation).
Context
Current tests verify schema generation but don't validate that schemas can actually validate real output data. This ensures schemas are not just structurally correct but functionally useful.
Implementation
Add new test function TestGeneratedSchemasValidateRealOutput in pkg/cli/mcp_schema_test.go:
func TestGeneratedSchemasValidateRealOutput(t *testing.T) {
// Test LogsData
schema, err := GenerateOutputSchema[LogsData]()
require.NoError(t, err)
resolved, err := schema.Resolve(&jsonschema.ResolveOptions{})
require.NoError(t, err)
data := LogsData{
Summary: "Test summary",
Runs: []RunData{{WorkflowName: "test-workflow"}},
}
jsonBytes, _ := json.Marshal(data)
var jsonValue map[string]any
json.Unmarshal(jsonBytes, &jsonValue)
err = resolved.Validate(jsonValue)
require.NoError(t, err, "Schema should validate real LogsData output")
// Add similar tests for AuditData and WorkflowStatus
}Files to Modify
pkg/cli/mcp_schema_test.go- Add new test function
Acceptance Criteria
- Test validates LogsData schema against real data
- Test validates AuditData schema against real data
- Test validates WorkflowStatus schema against real data
- Tests use schema.Resolve() and Validate() correctly
- All tests pass
Related to [plan] Upgrade and enhance google/jsonschema-go integration #6830
AI generated by Plan Command for discussion #6818
Reactions are currently unavailable