mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Def, Request, DirID, and Source said too little, and short variables and doc comments that skip their name hid intent. varnamelen and staticcheck ST1020-22 now keep both from coming back.
30 lines
683 B
Go
30 lines
683 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, statements ...string) {
|
|
t.Helper()
|
|
require.NoError(t, os.MkdirAll(filepath.Dir(path), 0o755))
|
|
database, err := sql.Open("sqlite", path)
|
|
require.NoError(t, err)
|
|
defer database.Close()
|
|
for _, statement := range statements {
|
|
_, err = database.Exec(statement)
|
|
require.NoError(t, err)
|
|
}
|
|
}
|