Replay explanations through shared history selections
This commit is contained in:
@@ -40,6 +40,8 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
|
||||
builder := newHistoryBuilder()
|
||||
builder.observeBaseline(baseline)
|
||||
builder.observeSourceEvidence(assembly.current.root, assembly.current.origins, assembly.current.applications, assembly.current.overlays)
|
||||
builder.model.final = assembly.current.root
|
||||
builder.registerDocumentRoot(assembly.current.root)
|
||||
model := builder.freeze()
|
||||
|
||||
defaultPath := Keys("defaults", "nullable")
|
||||
@@ -87,6 +89,30 @@ func TestHistorySourceObservationsPreserveRawAndCompositeDefinitions(t *testing.
|
||||
if emptySummary == nil || len(emptySummary.contributions) != 2 || emptySummary.contributions[0].id != 0 || emptySummary.contributions[1].id != 1 {
|
||||
t.Fatalf("empty mapping summary contribution references = %#v", emptySummary)
|
||||
}
|
||||
|
||||
metadata := Metadata{historyModel: model}
|
||||
metadataHistory := metadata.History(Keys("section", "empty"))
|
||||
var compositeSources []string
|
||||
for _, change := range metadataHistory {
|
||||
if len(change.Origin.Locations) > 1 {
|
||||
compositeSources = locationSourceIDs(change.Origin.Locations)
|
||||
}
|
||||
}
|
||||
inspection := &Inspection{
|
||||
metadata: metadata, baseline: baseline, final: assembly.current.root,
|
||||
immutableLookup: buildDocumentLookup(assembly.current.root),
|
||||
}
|
||||
explanation, explained := inspection.Explain(Keys("section", "empty"))
|
||||
var contributionSources []string
|
||||
for _, change := range explanation.History {
|
||||
if change.Origin.Layer == LayerBase || change.Origin.Layer == LayerOverlay {
|
||||
contributionSources = append(contributionSources, locationSourceIDs(change.Origin.Locations)...)
|
||||
}
|
||||
}
|
||||
if !explained || !reflect.DeepEqual(compositeSources, []string{"base", "overlay"}) ||
|
||||
!reflect.DeepEqual(contributionSources, []string{"base", "overlay"}) {
|
||||
t.Fatalf("metadata composite attribution and explanation contributions differ: metadata %#v, explanation %#v", metadataHistory, explanation.History)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHistorySourceReplacementTracksConcreteBeforeAndAfterShapes(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user