aboutsummaryrefslogtreecommitdiff
path: root/internal/validate/local_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-28 04:30:11 -0400
committerhistoria <[not public]>2026-06-28 04:30:11 -0400
commitfffc132263ab7d3c402992bffbaae4790161f7a7 (patch)
tree91151c29c93517dff15a91fec24f36ee98bc38bf /internal/validate/local_test.go
parent82c025b3f3e5cac82800ab9d7f11dcb4e3aa884b (diff)
downloadthehouseoficarus-fffc132263ab7d3c402992bffbaae4790161f7a7.tar.gz
feat: startup validation of opposite-direction exits between rooms
Diffstat (limited to 'internal/validate/local_test.go')
-rw-r--r--internal/validate/local_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/validate/local_test.go b/internal/validate/local_test.go
index 23bf8ca..d37838e 100644
--- a/internal/validate/local_test.go
+++ b/internal/validate/local_test.go
@@ -116,6 +116,52 @@ objects:
}
}
+func TestValidateExitReciprocityOK(t *testing.T) {
+ dir := t.TempDir()
+ writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Room One
+exits:
+ north: 2
+`)
+ writeFile(t, filepath.Join(dir, "rooms", "2.yaml"), `name: Room Two
+exits:
+ south: 1
+`)
+ issues := validateExitReciprocity(newSource(dir))
+ if len(issues) != 0 {
+ t.Errorf("expected no issues for correct reciprocal exits, got: %+v", issues)
+ }
+}
+
+func TestValidateExitReciprocityMismatch(t *testing.T) {
+ dir := t.TempDir()
+ writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Room One
+exits:
+ down: 2
+`)
+ writeFile(t, filepath.Join(dir, "rooms", "2.yaml"), `name: Room Two
+exits:
+ south: 1
+`)
+ issues := validateExitReciprocity(newSource(dir))
+ if !containsMsg(issues, "not the expected opposite direction") {
+ t.Errorf("expected mismatch warning, got: %+v", issues)
+ }
+}
+
+func TestValidateExitReciprocityOneWay(t *testing.T) {
+ dir := t.TempDir()
+ writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Room One
+exits:
+ east: 2
+`)
+ writeFile(t, filepath.Join(dir, "rooms", "2.yaml"), `name: Room Two
+`)
+ issues := validateExitReciprocity(newSource(dir))
+ if len(issues) != 0 {
+ t.Errorf("expected no issues for one-way exit, got: %+v", issues)
+ }
+}
+
func TestValidateRoomsPartialNameSiblingsOK(t *testing.T) {
dir := t.TempDir()
writeFile(t, filepath.Join(dir, "rooms", "1.yaml"), `name: Test Room