feat: add CountEntries to skip decryption for list --detail (#562)

* feat: add CountEntries to skip decryption for list --detail (#549)
* test: add CountEntries and countCategory tests at browser level
* fix: address review feedback on CountRows and countLocalStorage
* test: add CountRows unit tests
This commit is contained in:
Roger
2026-04-07 22:28:39 +08:00
committed by GitHub
parent 5f42d4fe5f
commit b3bbc0dadf
40 changed files with 1009 additions and 101 deletions
+23 -3
View File
@@ -7,14 +7,18 @@ import (
"github.com/stretchr/testify/require"
)
func TestExtractBookmarks(t *testing.T) {
// Bookmarks require JOIN: moz_bookmarks.fk = moz_places.id
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozBookmarksSchema},
func setupMozBookmarkDB(t *testing.T) string {
t.Helper()
return createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozBookmarksSchema},
insertMozPlace(1, "https://go.dev", "Go", 0, 0),
insertMozPlace(2, "https://github.com", "GitHub", 0, 0),
insertMozBookmark(1, 1, 1, "Go Website", 1700000000000000),
insertMozBookmark(2, 2, 1, "GitHub", 1710000000000000),
)
}
func TestExtractBookmarks(t *testing.T) {
path := setupMozBookmarkDB(t)
got, err := extractBookmarks(path)
require.NoError(t, err)
@@ -29,3 +33,19 @@ func TestExtractBookmarks(t *testing.T) {
assert.Equal(t, "url", got[0].Folder) // type=1 → "url"
assert.False(t, got[0].CreatedAt.IsZero())
}
func TestCountBookmarks(t *testing.T) {
path := setupMozBookmarkDB(t)
count, err := countBookmarks(path)
require.NoError(t, err)
assert.Equal(t, 2, count)
}
func TestCountBookmarks_Empty(t *testing.T) {
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozBookmarksSchema})
count, err := countBookmarks(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}