Use references in D&D spell extraction
This commit is contained in:
@@ -51,6 +51,9 @@ func TestValidatorsApproveValidCandidate(t *testing.T) {
|
||||
t.Fatalf("SourceRefValidator.Validate() error = %v, want nil", err)
|
||||
}
|
||||
assertSingleDecision(t, sourceRefResult, sourceRefValidatorName, 7, true, validate.ReasonApproved)
|
||||
if len(sourceRefResult.Warnings) != 0 {
|
||||
t.Fatalf("warnings = %#v, want none", sourceRefResult.Warnings)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShapeValidatorRejectsMalformedPayload(t *testing.T) {
|
||||
@@ -167,6 +170,29 @@ func TestSourceRefValidatorRejectsInvalidRefs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceRefValidatorWarnsWhenSpellNameIsNotInCitedSource(t *testing.T) {
|
||||
candidate := validSpellCandidate(31)
|
||||
payload := validSpellPayload()
|
||||
payload.Spell = "Shield"
|
||||
candidate.Payload = mustSpellPayload(t, payload)
|
||||
|
||||
result, err := SourceRefValidator{}.Validate(context.Background(), contracts.ValidationRequest{
|
||||
Source: promptSourceDocument(),
|
||||
Candidates: []artifacts.ArtifactCandidate{candidate},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("SourceRefValidator.Validate() error = %v, want nil", err)
|
||||
}
|
||||
assertSingleDecision(t, result, sourceRefValidatorName, 31, true, validate.ReasonApproved)
|
||||
if len(result.Warnings) != 1 {
|
||||
t.Fatalf("warnings = %#v, want one relatedness warning", result.Warnings)
|
||||
}
|
||||
warning := result.Warnings[0]
|
||||
if warning.ReasonCode != reasonSpellNotNearSource || !strings.Contains(warning.Message, "Shield") {
|
||||
t.Fatalf("warning = %#v, want spell relatedness warning", warning)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceRefValidatorRequiresSourceDocument(t *testing.T) {
|
||||
_, err := SourceRefValidator{}.Validate(context.Background(), contracts.ValidationRequest{
|
||||
Candidates: []artifacts.ArtifactCandidate{validSpellCandidate(19)},
|
||||
|
||||
Reference in New Issue
Block a user