Share the D&D NPC registry and prompt grounding
This commit is contained in:
28
internal/modules/dnd/shared/diagnostics/diagnostics_test.go
Normal file
28
internal/modules/dnd/shared/diagnostics/diagnostics_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package diagnostics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func TestAggregateEnforcesByteBudgetAndReportsOmissions(t *testing.T) {
|
||||
issues := make([]string, MaxIssues)
|
||||
for index := range issues {
|
||||
issues[index] = fmt.Sprintf("issue-%d-%s", index, strings.Repeat("火", MaxDisplayedRunes))
|
||||
}
|
||||
|
||||
message := Aggregate("invalid D&D data", issues)
|
||||
if !utf8.ValidString(message) || len([]byte(message)) > MaxMessageBytes {
|
||||
t.Fatalf("Aggregate() returned invalid or oversized message: bytes=%d message=%q", len([]byte(message)), message)
|
||||
}
|
||||
displayed := strings.Count(message, "issue-")
|
||||
if displayed == 0 || displayed >= len(issues) {
|
||||
t.Fatalf("Aggregate() displayed %d issues, want byte-budget omission", displayed)
|
||||
}
|
||||
wantOmitted := fmt.Sprintf("%d additional issue(s) omitted", len(issues)-displayed)
|
||||
if !strings.Contains(message, wantOmitted) {
|
||||
t.Fatalf("Aggregate() = %q, want %q", message, wantOmitted)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user