diff options
Diffstat (limited to 'internal/player/store_test.go')
| -rw-r--r-- | internal/player/store_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/player/store_test.go b/internal/player/store_test.go index 593e9d1..2987d09 100644 --- a/internal/player/store_test.go +++ b/internal/player/store_test.go @@ -79,3 +79,31 @@ func TestAccountStoreIgnoresNonYAMLFiles(t *testing.T) { } } } + +func TestLoadCharacterReconcilesNameToStem(t *testing.T) { + s := testAccountStore(t) + if err := os.WriteFile(s.CharPath("alice"), []byte("name: WRONG\nroom_id: 1\n"), 0600); err != nil { + t.Fatal(err) + } + p, err := s.LoadCharacter("alice") + if err != nil { + t.Fatal(err) + } + if p.Name != "alice" { + t.Fatalf("LoadCharacter reconciled name to %q, want %q", p.Name, "alice") + } +} + +func TestLoadAccountReconcilesNameToStem(t *testing.T) { + s := testAccountStore(t) + if err := os.WriteFile(s.AccountPath("alice"), []byte("name: WRONG\n"), 0600); err != nil { + t.Fatal(err) + } + acc, err := s.LoadAccount("alice") + if err != nil { + t.Fatal(err) + } + if acc.Name != "alice" { + t.Fatalf("LoadAccount reconciled name to %q, want %q", acc.Name, "alice") + } +} |
