Improve D&D validation reliability
This commit is contained in:
@@ -6,9 +6,40 @@ import (
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
func TestCorrectionsGroupRulesBeforeContextAndHideKeys(t *testing.T) {
|
||||
var corrections Corrections
|
||||
corrections.Add("internal-kind", "Use a supported kind.", "Affected goblin at source unit 4.")
|
||||
corrections.Add("internal-kind", "Use a supported kind.", "Affected ogre at source units 8-9.")
|
||||
corrections.Add("internal-kind", "Use a supported kind.", "Affected goblin at source unit 4.")
|
||||
corrections.Add("name", "Provide a contextual name.", "Affected unnamed record at source unit 12.")
|
||||
|
||||
guidance := corrections.Guidance("Correct every record")
|
||||
if strings.Contains(guidance, "internal-kind") {
|
||||
t.Fatalf("Guidance() exposed grouping key: %q", guidance)
|
||||
}
|
||||
if strings.Count(guidance, "Use a supported kind.") != 1 || strings.Count(guidance, "Affected goblin") != 1 {
|
||||
t.Fatalf("Guidance() did not de-duplicate rules and records: %q", guidance)
|
||||
}
|
||||
if strings.Index(guidance, "Use a supported kind.") > strings.Index(guidance, "Affected goblin") {
|
||||
t.Fatalf("Guidance() = %q, want rules before records", guidance)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceRangeUsesOnlyTranscriptPositions(t *testing.T) {
|
||||
refs := []source.SourceRef{
|
||||
{SourceID: "opaque-source", StartUnitID: 8, EndUnitID: 10},
|
||||
{SourceID: "opaque-source", StartUnitID: 12, EndUnitID: 12},
|
||||
}
|
||||
got := SourceRange(refs)
|
||||
if strings.Contains(got, "opaque-source") || !strings.Contains(got, "8-10") || !strings.Contains(got, "first of 2") {
|
||||
t.Fatalf("SourceRange() = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAggregateEnforcesByteBudgetAndReportsOmissions(t *testing.T) {
|
||||
issues := make([]string, MaxIssues)
|
||||
for index := range issues {
|
||||
|
||||
Reference in New Issue
Block a user