Finalize structured diagnostic aggregation
This commit is contained in:
@@ -445,17 +445,13 @@ func TestMaterializeReferencesWarnsForEmptyFiles(t *testing.T) {
|
||||
writeReferenceFile(t, path, nil)
|
||||
|
||||
resolved := resolvedPipelineWithReference(t, "roster", "empty.txt", contracts.ReferenceBindingSourceConfig, contracts.ReferenceSlot{Name: "roster"})
|
||||
materialized, warnings, err := MaterializeReferences(resolved, referenceCatalog(t, []contracts.ReferenceSlot{{Name: "roster"}}), ReferenceMaterializationOptions{
|
||||
materialized, diagnostics, err := MaterializeReferences(resolved, referenceCatalog(t, []contracts.ReferenceSlot{{Name: "roster"}}), ReferenceMaterializationOptions{
|
||||
ConfigPath: filepath.Join(configDir, "config.yml"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("MaterializeReferences() error = %v, want nil", err)
|
||||
}
|
||||
if len(warnings) != 1 || warnings[0].ReasonCode != "empty_reference" {
|
||||
t.Fatalf("warnings = %#v, want empty reference warning", warnings)
|
||||
}
|
||||
diagnostics := ReferenceDiagnostics(warnings)
|
||||
if len(diagnostics) != 1 || diagnostics[0].Disposition != contracts.DiagnosticDispositionWarning || diagnostics[0].Category != contracts.DiagnosticCategoryConfiguration || diagnostics[0].ReasonCode != "empty_reference" || diagnostics[0].OccurrenceCount != 1 || !reflect.DeepEqual(diagnostics[0].Samples, []contracts.DiagnosticSample{{Scope: warnings[0].Scope, Message: warnings[0].Message}}) {
|
||||
if len(diagnostics) != 1 || diagnostics[0].Disposition != contracts.DiagnosticDispositionWarning || diagnostics[0].Category != contracts.DiagnosticCategoryConfiguration || diagnostics[0].ReasonCode != "empty_reference" || diagnostics[0].OccurrenceCount != 1 || len(diagnostics[0].Samples) != 1 {
|
||||
t.Fatalf("diagnostics = %#v, want structured empty-reference signal", diagnostics)
|
||||
}
|
||||
item := materialized.Steps[0].ArtifactLanes[0].ExtractReferences.ReferenceSet.Slots["roster"].Items[0]
|
||||
@@ -487,13 +483,13 @@ func TestMaterializeReferencesWarningScopesIncludeTargetContext(t *testing.T) {
|
||||
t.Fatalf("ResolvePipeline() error = %v, want nil", err)
|
||||
}
|
||||
|
||||
_, warnings, err := MaterializeReferences(resolved, catalog, ReferenceMaterializationOptions{
|
||||
_, diagnostics, err := MaterializeReferences(resolved, catalog, ReferenceMaterializationOptions{
|
||||
ConfigPath: filepath.Join(configDir, "config.yml"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("MaterializeReferences() error = %v, want nil", err)
|
||||
}
|
||||
got := warningScopes(warnings)
|
||||
got := diagnosticScopes(diagnostics)
|
||||
want := []string{
|
||||
"pipeline.baseline.chunk.reference.scene_guide",
|
||||
"pipeline.baseline.lane.events.extract.reference.roster",
|
||||
@@ -625,10 +621,10 @@ func referenceCatalogForTargets(t *testing.T, chunkSlots, extractSlots, mergeSlo
|
||||
)
|
||||
}
|
||||
|
||||
func warningScopes(warnings []contracts.Warning) []string {
|
||||
scopes := make([]string, 0, len(warnings))
|
||||
for _, warning := range warnings {
|
||||
scopes = append(scopes, warning.Scope)
|
||||
func diagnosticScopes(diagnostics []contracts.ProducerDiagnostic) []string {
|
||||
scopes := make([]string, 0, len(diagnostics))
|
||||
for _, diagnostic := range diagnostics {
|
||||
scopes = append(scopes, diagnostic.Samples[0].Scope)
|
||||
}
|
||||
sort.Strings(scopes)
|
||||
return scopes
|
||||
|
||||
Reference in New Issue
Block a user