Add output schema registry and public contract docs
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type ProcessReport struct {
|
||||
ReportMetadata ReportMetadata `json:"report_metadata"`
|
||||
Phase string `json:"phase"`
|
||||
Status string `json:"status"`
|
||||
Operation string `json:"operation"`
|
||||
@@ -32,6 +33,18 @@ type ProcessReport struct {
|
||||
ModuleResults []ModuleReport `json:"module_results,omitempty"`
|
||||
}
|
||||
|
||||
const (
|
||||
DefaultProcessReportSchemaName = "audita-process-report"
|
||||
DefaultProcessReportSchemaVersion = "v1"
|
||||
)
|
||||
|
||||
type ReportMetadata struct {
|
||||
ReportSchemaName string `json:"report_schema_name"`
|
||||
ReportSchemaVersion string `json:"report_schema_version"`
|
||||
OutputSchema string `json:"output_schema"`
|
||||
ConfigVersion *int `json:"config_version,omitempty"`
|
||||
}
|
||||
|
||||
type ModuleReport struct {
|
||||
ModuleKey string `json:"module_key"`
|
||||
ModuleInstance string `json:"module_instance"`
|
||||
|
||||
@@ -11,6 +11,11 @@ import (
|
||||
func TestProcessReportModuleResultsJSONSuccessAndSkipped(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
report := ProcessReport{
|
||||
ReportMetadata: ReportMetadata{
|
||||
ReportSchemaName: DefaultProcessReportSchemaName,
|
||||
ReportSchemaVersion: DefaultProcessReportSchemaVersion,
|
||||
OutputSchema: "bare-segments",
|
||||
},
|
||||
Phase: "default_pipeline",
|
||||
Status: "success",
|
||||
ModuleResults: []ModuleReport{
|
||||
@@ -75,11 +80,21 @@ func TestProcessReportModuleResultsJSONSuccessAndSkipped(t *testing.T) {
|
||||
if parsed.ModulesSummary == nil || parsed.ModulesSummary.TotalSkippedChanges != 1 {
|
||||
t.Fatalf("unexpected module summary: %+v", parsed.ModulesSummary)
|
||||
}
|
||||
if parsed.ReportMetadata.ReportSchemaName != DefaultProcessReportSchemaName ||
|
||||
parsed.ReportMetadata.ReportSchemaVersion != DefaultProcessReportSchemaVersion ||
|
||||
parsed.ReportMetadata.OutputSchema != "bare-segments" {
|
||||
t.Fatalf("unexpected report metadata after roundtrip: %+v", parsed.ReportMetadata)
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessReportModuleResultsJSONFailedModule(t *testing.T) {
|
||||
now := time.Now().UTC()
|
||||
report := ProcessReport{
|
||||
ReportMetadata: ReportMetadata{
|
||||
ReportSchemaName: DefaultProcessReportSchemaName,
|
||||
ReportSchemaVersion: DefaultProcessReportSchemaVersion,
|
||||
OutputSchema: "audita-v1",
|
||||
},
|
||||
Phase: "default_pipeline",
|
||||
Status: "failed",
|
||||
ModuleResults: []ModuleReport{
|
||||
@@ -106,6 +121,9 @@ func TestProcessReportModuleResultsJSONFailedModule(t *testing.T) {
|
||||
if _, ok := decoded["module_results"]; !ok {
|
||||
t.Fatalf("expected module_results field")
|
||||
}
|
||||
if _, ok := decoded["report_metadata"]; !ok {
|
||||
t.Fatalf("expected report_metadata field")
|
||||
}
|
||||
if _, ok := decoded["modules_summary"]; !ok {
|
||||
t.Fatalf("expected modules_summary field")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user