inital commit

This commit is contained in:
2026-05-25 22:27:18 +02:00
commit 965f9d6ad4
91 changed files with 28963 additions and 0 deletions

28
fixtures_test.go Normal file
View File

@@ -0,0 +1,28 @@
package fa
import (
"os"
"path/filepath"
"testing"
)
// fixturesDir is where captured FA HTML responses live. The refresh tool
// (see fixtures_refresh_test.go, build tag `fixtures`) writes here.
const fixturesDir = "testdata/html"
// loadFixture reads a captured HTML fixture by name and skips the test if
// the file is missing. Pairs with the `fixtures` build-tagged refresh test:
// if you've never run the refresh, parser tests against real HTML are skipped
// cleanly instead of failing.
func loadFixture(t *testing.T, name string) []byte {
t.Helper()
path := filepath.Join(fixturesDir, name)
data, err := os.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
t.Skipf("fixture %s not present run `go test -tags=fixtures` with FA_* env vars to refresh", path)
}
t.Fatalf("read fixture %s: %v", path, err)
}
return data
}