Files
HackBrowserData/internal/browser/browsertest/browsertest.go
T
Roger 3e9150249c refactor: rename core types and spell out every name (#677)
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.
2026-11-02 11:06:05 +08:00

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)
}
}