mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-08 21:37:49 +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 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user