aboutsummaryrefslogtreecommitdiff
path: root/internal/bookmarks/bookmarks_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:39:35 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 16:39:35 +0200
commit102bf0c522c94d36f8363c38711621fe5ad18555 (patch)
treec5be424abf0b2a2316e318502ff698f6029228a5 /internal/bookmarks/bookmarks_test.go
parent3eb99c1dd63565fbc1f5bf5af7fc8e835aad182e (diff)
downloadlectio-102bf0c522c94d36f8363c38711621fe5ad18555.tar.gz
lectio-102bf0c522c94d36f8363c38711621fe5ad18555.zip
bookmarks: store as universal TSV (header row) with one-time JSON migration; tui note box wraps long notes with hanging indent + hard-break; v0.21.0
Diffstat (limited to 'internal/bookmarks/bookmarks_test.go')
-rw-r--r--internal/bookmarks/bookmarks_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/bookmarks/bookmarks_test.go b/internal/bookmarks/bookmarks_test.go
index 40e10e0..337d50d 100644
--- a/internal/bookmarks/bookmarks_test.go
+++ b/internal/bookmarks/bookmarks_test.go
@@ -1,6 +1,8 @@
package bookmarks
import (
+ "os"
+ "path/filepath"
"testing"
)
@@ -44,3 +46,24 @@ func TestParseTags(t *testing.T) {
t.Errorf("ParseTags = %v", got)
}
}
+
+func TestMigrateJSONToTSV(t *testing.T) {
+ dir := t.TempDir()
+ t.Setenv("XDG_DATA_HOME", dir)
+ os.MkdirAll(filepath.Join(dir, "lectio"), 0o755)
+ if err := os.WriteFile(filepath.Join(dir, "lectio", "bookmarks.json"),
+ []byte(`[{"id":"a1","book":"John","chapter":3,"verse":16,"note":"a\tnote","tags":["grace"],"created":"2026-07-24T10:00:00Z"}]`), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ s := Open() // migrates JSON -> TSV
+ got, _ := s.List("")
+ if len(got) != 1 || got[0].Book != "John" || got[0].Verse != 16 || got[0].Note != "a note" {
+ t.Fatalf("migrated = %+v (tab in note should be sanitized)", got)
+ }
+ if _, err := os.Stat(filepath.Join(dir, "lectio", "bookmarks.tsv")); err != nil {
+ t.Errorf("tsv not written: %v", err)
+ }
+ if _, err := os.Stat(filepath.Join(dir, "lectio", "bookmarks.json.migrated")); err != nil {
+ t.Errorf("json not backed up: %v", err)
+ }
+}