Finalize structured diagnostic aggregation
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func TestValidatorApprovesValidSourceReferences(t *testing.T) {
|
||||
result, err := New(Options{}).Validate(context.Background(), requestWithValue(validDocument(), validNPCRegistry()))
|
||||
if err != nil || !result.Approved || len(result.Warnings) != 0 {
|
||||
if err != nil || !result.Approved {
|
||||
t.Fatalf("Validate() = %#v, %v; want approval", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +49,12 @@ func (v *Validator) Validate(_ context.Context, req contracts.TypedValidationReq
|
||||
}
|
||||
citedTexts[npcIndex] = citedText
|
||||
}
|
||||
var warnings []contracts.Warning
|
||||
var warnings []diagnostics.Finding
|
||||
for npcIndex, npc := range req.Value.NPCs {
|
||||
if npcAppearsInCitedText(citedTexts[npcIndex], npc) {
|
||||
continue
|
||||
}
|
||||
warnings = append(warnings, contracts.Warning{
|
||||
warnings = append(warnings, diagnostics.Finding{
|
||||
Scope: fmt.Sprintf("npcs[%d]", npcIndex),
|
||||
ReasonCode: ReasonCode,
|
||||
Message: fmt.Sprintf("NPC %s was not found in cited source text", diagnostics.Quote(npc.Name)),
|
||||
|
||||
@@ -36,7 +36,7 @@ func TestValidatorWarnsAtMostOncePerNPCForUnrelatedCitations(t *testing.T) {
|
||||
{ID: "one", Name: "Missing\nName", SourceRefs: []source.SourceRef{{SourceID: "session", StartUnitID: 1, EndUnitID: 1}, {SourceID: "session", StartUnitID: 1, EndUnitID: 1}}},
|
||||
}}
|
||||
result, err := New(Options{}).Validate(context.Background(), contracts.TypedValidationRequest[dnd.NPCRegistry]{Source: relatednessDocument(), Value: value})
|
||||
if err != nil || !result.Approved || len(result.Warnings) != 0 || len(result.Diagnostics) != 1 {
|
||||
if err != nil || !result.Approved || len(result.Diagnostics) != 1 {
|
||||
t.Fatalf("Validate() = %#v, %v; want one advisory", result, err)
|
||||
}
|
||||
diagnostic := result.Diagnostics[0]
|
||||
|
||||
Reference in New Issue
Block a user