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 TestExtractDownloads(t *testing.T) {
// Downloads require JOIN: moz_annos.place_id = moz_places.id
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozAnnosSchema},
func setupMozDownloadDB(t *testing.T) string {
t.Helper()
return createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozAnnosSchema},
insertMozPlace(1, "https://example.com/old.zip", "Old File", 0, 0),
insertMozPlace(2, "https://example.com/new.pdf", "New File", 0, 0),
insertMozAnno(1, "/tmp/old.zip", 1700000000000000),
insertMozAnno(2, "/tmp/new.pdf", 1710000000000000),
)
}
func TestExtractDownloads(t *testing.T) {
path := setupMozDownloadDB(t)
got, err := extractDownloads(path)
require.NoError(t, err)
@@ -28,3 +32,19 @@ func TestExtractDownloads(t *testing.T) {
assert.Equal(t, "/tmp/new.pdf", got[0].TargetPath)
assert.False(t, got[0].StartTime.IsZero())
}
func TestCountDownloads(t *testing.T) {
path := setupMozDownloadDB(t)
count, err := countDownloads(path)
require.NoError(t, err)
assert.Equal(t, 2, count)
}
func TestCountDownloads_Empty(t *testing.T) {
path := createTestDB(t, "places.sqlite", []string{mozPlacesSchema, mozAnnosSchema})
count, err := countDownloads(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}