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 TestExtractLocalStorage(t *testing.T) {
path := createTestDB(t, "webappsstore.sqlite", []string{webappsstore2Schema},
func setupWebappsDB(t *testing.T) string {
t.Helper()
return createTestDB(t, "webappsstore.sqlite", []string{webappsstore2Schema},
insertWebappsstore("moc.buhtig.:https:443", "theme", "dark"),
insertWebappsstore("moc.buhtig.:https:443", "lang", "en"),
insertWebappsstore("moc.elpmaxe.:http:8080", "token", "abc123"),
)
}
func TestExtractLocalStorage(t *testing.T) {
path := setupWebappsDB(t)
got, err := extractLocalStorage(path)
require.NoError(t, err)
@@ -28,6 +33,22 @@ func TestExtractLocalStorage(t *testing.T) {
assert.Equal(t, "abc123", byKey["http://example.com:8080/token"])
}
func TestCountLocalStorage(t *testing.T) {
path := setupWebappsDB(t)
count, err := countLocalStorage(path)
require.NoError(t, err)
assert.Equal(t, 3, count)
}
func TestCountLocalStorage_Empty(t *testing.T) {
path := createTestDB(t, "webappsstore.sqlite", []string{webappsstore2Schema})
count, err := countLocalStorage(path)
require.NoError(t, err)
assert.Equal(t, 0, count)
}
func TestParseOriginKey(t *testing.T) {
tests := []struct {
name string