From 102bf0c522c94d36f8363c38711621fe5ad18555 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Fri, 24 Jul 2026 16:39:35 +0200 Subject: 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 --- internal/bookmarks/bookmarks_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'internal/bookmarks/bookmarks_test.go') 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) + } +} -- cgit v1.3