diff options
Diffstat (limited to 'internal/validate/local_test.go')
| -rw-r--r-- | internal/validate/local_test.go | 46 |
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 |
