Files
HackBrowserData/internal/browser/browsertest/browsertest.go
T
Roger 07b66adc4d test: move compat tests into the packages they cover (#669)
The pipeline goldens now live in app, export in export, and keys.json in masterkey, each with its own
testdata; cmd keeps the flag and list goldens. Shared fixtures and golden helpers became the
internal/browser/browsertest and internal/golden packages. The binary is byte-identical.
2026-10-29 16:12:50 +08:00

30 lines
645 B
Go

package browsertest
import (
"database/sql"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
_ "modernc.org/sqlite"
)
func fixtureWrite(t *testing.T, path, content string) {
t.Helper()
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
require.NoError(t, os.WriteFile(path, []byte(content), 0o644))
}
func fixtureSQLite(t *testing.T, path string, stmts ...string) {
t.Helper()
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
db, err := sql.Open("sqlite", path)
require.NoError(t, err)
defer db.Close()
for _, stmt := range stmts {
_, err = db.Exec(stmt)
require.NoError(t, err)
}
}