Remove superseded history attribution paths
This commit is contained in:
@@ -63,9 +63,6 @@ func TestInheritanceEvidenceUsesOrderedPayloadAndConcreteTransferShapes(t *testi
|
||||
displaced[0].attribution.origin.Locations[0].SourceID != "child" {
|
||||
t.Fatalf("pre-transfer child shape was not retained: %#v", displaced)
|
||||
}
|
||||
if public := projectedInheritanceChanges(displacedPath, model.inheritancePayloads[0].operations[1]); len(public) != 0 {
|
||||
t.Fatalf("displaced child path unexpectedly projected publicly: %#v", public)
|
||||
}
|
||||
if builder.scratch != nil {
|
||||
t.Fatal("frozen builder unexpectedly retained scratch")
|
||||
}
|
||||
@@ -74,31 +71,41 @@ func TestInheritanceEvidenceUsesOrderedPayloadAndConcreteTransferShapes(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
func TestInheritanceResolverSharesProjectionAttribution(t *testing.T) {
|
||||
func TestInheritanceModelSharesProjectionAttribution(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
from, to, reference := Keys("parents", "base"), Keys("children", "item"), Keys("parents", "base")
|
||||
path := to.Key("nested").Key("value")
|
||||
parent := Origin{Layer: LayerBase, Locations: []Location{{SourceID: "base"}}}
|
||||
child := Origin{Layer: LayerOverlay, Locations: []Location{{SourceID: "child"}}}
|
||||
parentDocument := parseDocumentForDecode(t, "nested: {value: parent}\n")
|
||||
effectiveDocument := parseDocumentForDecode(t, "nested: {value: child}\n")
|
||||
operation := inheritanceOperation{
|
||||
transfer: &inheritanceTransfer{from: from, to: to, reference: reference},
|
||||
parent: parentDocument,
|
||||
effective: effectiveDocument,
|
||||
parentOrigins: map[string]Origin{from.Key("nested").Key("value").String(): parent},
|
||||
effectiveOrigins: map[string]Origin{path.String(): child},
|
||||
}
|
||||
selections := resolveInheritanceAttribution(operation, path)
|
||||
if len(selections) != 2 || selections[0].kind != inheritanceEvidenceParent || selections[1].kind != inheritanceEvidenceChild {
|
||||
t.Fatalf("shared resolver selections = %#v", selections)
|
||||
root := parseDocumentForDecode(t, "children: {item: {nested: {value: old}}}\n")
|
||||
builder := newHistoryBuilder()
|
||||
builder.setScratch(root)
|
||||
builder.observeInheritanceEvidence([]inheritanceOperation{operation})
|
||||
model := builder.freeze()
|
||||
selections := model.selectHistory(path)
|
||||
if len(selections) != 2 || selections[0].role != historyRoleOperation || selections[1].role != historyRoleOperation {
|
||||
t.Fatalf("model inheritance selections = %#v", selections)
|
||||
}
|
||||
if selections[0].path.String() != selections[1].path.String() || selections[0].origin.Operation != ChangeInheritance || selections[1].origin.Operation != ChangeInheritance {
|
||||
t.Fatalf("parent and child attributions did not share one resolver: %#v", selections)
|
||||
if selections[0].reportedPath.String() != to.String() || selections[1].reportedPath.String() != to.String() ||
|
||||
selections[0].attribution.origin.Operation != ChangeInheritance || selections[1].attribution.origin.Operation != ChangeInheritance {
|
||||
t.Fatalf("parent and child attributions did not share the model owner: %#v", selections)
|
||||
}
|
||||
changes := projectedInheritanceChanges(path, operation)
|
||||
if len(changes) != 2 || changes[0].Origin.Locations[0].SourceID != selections[0].origin.Locations[0].SourceID ||
|
||||
changes[1].Origin.Locations[0].SourceID != selections[1].origin.Locations[0].SourceID ||
|
||||
changes[0].Dependencies[0].String() != from.String() || changes[0].Dependencies[1].String() != reference.String() ||
|
||||
changes[1].Dependencies[0].String() != reference.String() {
|
||||
t.Fatalf("metadata projection attribution = %#v; resolver = %#v", changes, selections)
|
||||
if selections[0].attribution.origin.Locations[0].SourceID != "base" ||
|
||||
selections[1].attribution.origin.Locations[0].SourceID != "child" ||
|
||||
len(selections[0].attribution.dependencies) != 2 || selections[0].attribution.dependencies[0].String() != from.String() ||
|
||||
selections[0].attribution.dependencies[1].String() != reference.String() ||
|
||||
len(selections[1].attribution.dependencies) != 1 || selections[1].attribution.dependencies[0].String() != reference.String() {
|
||||
t.Fatalf("model attribution dependencies or origins differ: %#v", selections)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user