mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-06 05:53:25 +01:00
test: pin today's output with compatibility goldens (#649)
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.
This commit is contained in:
1 parent
f4c05f861f
commit
fb86bd368e
22 files changed
+3607
-16
No files matched your search
@@ -0,0 +1,43 @@
|
||||
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
|
||||
}
|
||||
Reference in new issue
Block a user