From bc2d27f702e8d79fe9856fcaf7cd963cd20d4c56 Mon Sep 17 00:00:00 2001 From: SoXX Date: Tue, 2 Jun 2026 21:30:28 +0200 Subject: [PATCH] chore: add fixture-refresh helper script scripts/refresh-user-fixture.sh wraps the TestRefreshFixtures invocation: validates required env vars, warns on missing CF credentials, runs the refresh, and re-runs the user parser tests against the new fixture. --- scripts/refresh-user-fixture.sh | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 scripts/refresh-user-fixture.sh diff --git a/scripts/refresh-user-fixture.sh b/scripts/refresh-user-fixture.sh new file mode 100755 index 0000000..46e0437 --- /dev/null +++ b/scripts/refresh-user-fixture.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# Refresh testdata/html/user.html (and any other fixtures whose env vars are +# set) by re-running TestRefreshFixtures against live FA with your cookies. +# +# Required: +# FA_A, FA_B session cookies +# FA_TEST_USER your FA username (lowercase, e.g. soxx-thefennec) +# +# Strongly recommended (otherwise Cloudflare will likely block the request): +# CF_CLEARANCE cf_clearance cookie from the same browser session +# FA_UA the exact User-Agent that produced CF_CLEARANCE +# +# Usage: +# FA_A=... FA_B=... CF_CLEARANCE=... FA_UA="..." FA_TEST_USER=soxx-thefennec \ +# ./scripts/refresh-user-fixture.sh +# +# Or export the vars in your shell first, then just run the script. + +set -euo pipefail + +cd "$(dirname "$0")/.." + +missing=() +for var in FA_A FA_B FA_TEST_USER; do + if [[ -z "${!var:-}" ]]; then + missing+=("$var") + fi +done +if (( ${#missing[@]} )); then + echo "error: missing required env vars: ${missing[*]}" >&2 + exit 1 +fi + +if [[ -z "${CF_CLEARANCE:-}" || -z "${FA_UA:-}" ]]; then + echo "warning: CF_CLEARANCE or FA_UA not set; the request will likely hit a Cloudflare challenge" >&2 +fi + +echo "refreshing fixtures for user=$FA_TEST_USER" +go test -tags=fixtures -run TestRefreshFixtures -v ./... + +echo +echo "re-running user parser tests against the new fixture" +go test -run TestParseUser ./...