mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-06-04 19:48:01 +02:00
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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user