mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Phase 0, part 2: freeze the output files, keys.json, and archives today's code writes, so every later phase can prove it changes nothing.
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/moond4rk/hackbrowserdata/types"
|
|
)
|
|
|
|
func TestExtractGolden(t *testing.T) {
|
|
root := t.TempDir()
|
|
chromiumFixtureInstallations(t, root)
|
|
|
|
tests := []struct {
|
|
format string
|
|
golden string
|
|
jsonFallback bool
|
|
}{
|
|
{format: "csv", golden: "extract-csv.golden"},
|
|
{format: "json", golden: "extract-json.golden"},
|
|
{format: "cookie-editor", golden: "extract-cookie-editor.golden", jsonFallback: true},
|
|
}
|
|
for _, tt := range tests {
|
|
tt := tt
|
|
t.Run(tt.format, func(t *testing.T) {
|
|
out := extractGoldenRun(t, root, tt.format)
|
|
got := bundleDir(t, out)
|
|
if tt.jsonFallback {
|
|
assertJSONFallback(t, out, extractGoldenRun(t, root, "json"))
|
|
got = bundleFiles(t, out, "cookie.json")
|
|
}
|
|
assertGolden(t, tt.golden, got)
|
|
})
|
|
}
|
|
}
|
|
|
|
func extractGoldenRun(t *testing.T, root, format string) string {
|
|
t.Helper()
|
|
out := t.TempDir()
|
|
require.NoError(t, extractAndWrite(chromiumFixtureBrowsers(t, root), types.AllCategories, out, format, false))
|
|
return out
|
|
}
|