mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-08-22 00:17:16 +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,12 +7,17 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestExtractHistories(t *testing.T) {
|
||||
path := createTestDB(t, "History", urlsSchema,
|
||||
func setupHistoryDB(t *testing.T) string {
|
||||
t.Helper()
|
||||
return createTestDB(t, "History", urlsSchema,
|
||||
insertURL("https://github.com", "GitHub", 100, 13370000000000000),
|
||||
insertURL("https://go.dev", "Go Dev", 50, 13360000000000000),
|
||||
insertURL("https://example.com", "Example", 200, 13350000000000000),
|
||||
)
|
||||
}
|
||||
|
||||
func TestExtractHistories(t *testing.T) {
|
||||
path := setupHistoryDB(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 := setupHistoryDB(t)
|
||||
|
||||
count, err := countHistories(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 3, count)
|
||||
}
|
||||
|
||||
func TestCountHistories_Empty(t *testing.T) {
|
||||
path := createTestDB(t, "History", urlsSchema)
|
||||
|
||||
count, err := countHistories(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 0, count)
|
||||
}
|
||||
|
||||
func TestExtractHistories_FileNotFound(t *testing.T) {
|
||||
_, err := extractHistories("/nonexistent/History")
|
||||
require.Error(t, err)
|
||||
|
||||
Reference in New Issue
Block a user