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 -2
View File
@@ -7,12 +7,17 @@ import (
"github.com/stretchr/testify/require"
)
func TestExtractHistories(t *testing.T) {
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema},
func setupMozHistoryDB(t *testing.T) string {
t.Helper()
return createTestDB(t, "places.sqlite", []string{mozPlacesSchema},
insertMozPlace(1, "https://github.com", "GitHub", 100, 1700000000000000),
insertMozPlace(2, "https://go.dev", "Go", 50, 1710000000000000),
insertMozPlace(3, "https://example.com", "Example", 200, 1690000000000000),
)
}
func TestExtractHistories(t *testing.T) {
path := setupMozHistoryDB(t)
got, err := extractHistories(path)
require.NoError(t, err)
@@ -29,6 +34,22 @@ func TestExtractHistories(t *testing.T) {
assert.False(t, got[0].LastVisit.IsZero())
}
func TestCountHistories(t *testing.T) {
path := setupMozHistoryDB(t)
count, err := countHistories(path)
require.NoError(t, err)
assert.Equal(t, 3, count)
}
func TestCountHistories_Empty(t *testing.T) {
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema})
count, err := countHistories(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}
func TestExtractHistories_NullFields(t *testing.T) {
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema},
// last_visit_date=NULL, title=NULL — COALESCE should handle