diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-10 23:11:30 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-10 23:11:30 +0300 |
| commit | 65430e9876a32988839deb7a70dc1e42da21cf64 (patch) | |
| tree | e0de040cb53d5b90587908f2d55e86e49664fc35 /internal/store/store_test.go | |
| parent | 4b4b3665230faafbd994f09894cb07c8f9d4b359 (diff) | |
Release 0.28.2v0.28.2
Diffstat (limited to 'internal/store/store_test.go')
| -rw-r--r-- | internal/store/store_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 6d34d0c..02da883 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -138,3 +138,33 @@ func TestCardStoreScanWords(t *testing.T) { t.Errorf("ScanWords(nil) = %v; want 2 words", allWords) } } + +func TestCardStoreListCardDirectories(t *testing.T) { + tmpDir := t.TempDir() + + makeCard := func(id, word string) string { + cardDir := filepath.Join(tmpDir, id) + _ = os.MkdirAll(cardDir, 0755) + _ = os.WriteFile(filepath.Join(cardDir, "word.txt"), []byte(word), 0644) + return cardDir + } + + card2 := makeCard("card2", "куче") + makeCard("card1", "котка") + makeCard(".hidden", "hidden") + + cs := store.New(tmpDir) + cards := cs.ListCardDirectories(func(wordDir string) bool { + return wordDir != card2 + }) + + if len(cards) != 1 { + t.Fatalf("ListCardDirectories() returned %d cards, want 1", len(cards)) + } + if cards[0].Word != "котка" { + t.Fatalf("ListCardDirectories()[0].Word = %q, want %q", cards[0].Word, "котка") + } + if filepath.Base(cards[0].Path) != "card1" { + t.Fatalf("ListCardDirectories()[0].Path = %q, want base %q", cards[0].Path, "card1") + } +} |
