Move item registry reconciliation into shared operations
This commit is contained in:
@@ -57,27 +57,40 @@ func TestNormalizationCaptureRetainsFixedMappingAndEveryProposal(t *testing.T) {
|
||||
if err != nil || result.Outcome.Disposition != contracts.ProducerAccepted {
|
||||
t.Fatalf("normalization: %#v %v", result, err)
|
||||
}
|
||||
content, err := os.ReadFile(filepath.Join(recorder.Path(), "normalization", "originals.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var originals dnd.ItemRegistry
|
||||
if err := json.Unmarshal(content, &originals); err != nil || len(originals.Items) != 3 {
|
||||
t.Fatalf("fixed originals missing: %#v %v", originals, err)
|
||||
}
|
||||
content, err = os.ReadFile(filepath.Join(recorder.Path(), "normalization", "preparation.json"))
|
||||
content, err := os.ReadFile(filepath.Join(recorder.Path(), "preparation-domain.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var preparation struct {
|
||||
Mappings []any `json:"candidate_mappings"`
|
||||
Originals dnd.ItemRegistry `json:"originals"`
|
||||
Mappings []any `json:"candidate_mappings"`
|
||||
}
|
||||
if err := json.Unmarshal(content, &preparation); err != nil || len(preparation.Mappings) != 3 {
|
||||
if err := json.Unmarshal(content, &preparation); err != nil || len(preparation.Originals.Items) != 3 || len(preparation.Mappings) != 3 {
|
||||
t.Fatalf("fixed handle mapping missing: %s %v", content, err)
|
||||
}
|
||||
proposals, err := os.ReadDir(filepath.Join(recorder.Path(), "normalization", "proposals"))
|
||||
if err != nil || len(proposals) != 2 {
|
||||
t.Fatalf("revised proposals lost: %v %v", proposals, err)
|
||||
entries, err := os.ReadDir(filepath.Join(recorder.Path(), "interpretations"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var proposals int
|
||||
for _, entry := range entries {
|
||||
if !strings.HasSuffix(entry.Name(), "-domain.json") {
|
||||
continue
|
||||
}
|
||||
content, err := os.ReadFile(filepath.Join(recorder.Path(), "interpretations", entry.Name()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var evaluation struct {
|
||||
Proposal json.RawMessage `json:"proposal"`
|
||||
}
|
||||
if err := json.Unmarshal(content, &evaluation); err != nil || len(evaluation.Proposal) == 0 {
|
||||
t.Fatalf("proposal evidence = %s, %v", content, err)
|
||||
}
|
||||
proposals++
|
||||
}
|
||||
if proposals != 2 {
|
||||
t.Fatalf("revised proposals lost: %d", proposals)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user