packages.wenpai.net/test/capture-fixtures.sh
Scott Walkinshaw 3604622901
Replace shell smoke test with Go integration tests (#26)
* Replace shell smoke test with Go integration tests

Replaces the 480-line bash smoke test with Go integration tests that are
deterministic, fast, and self-contained. The new test infrastructure uses
fixture data and a mock wp.org server so tests run without network
dependencies on the WordPress.org API.

New files:
- Mock wp.org server (internal/wporg/mock_server.go) + API fixtures
- Test DB helpers (internal/testutil/testdb.go) for in-memory SQLite
- Integration smoke test covering full pipeline, HTTP endpoints,
  composer install, version pinning, and build integrity
- R2 sync test using gofakes3 for S3-compat verification
- Live canary test for nightly runs against real wp.org
- Fixture capture script (test/capture-fixtures.sh)
- Canary CI workflow (.github/workflows/canary.yml)

Changes:
- wporg.Client now supports configurable base URL via SetBaseURL()
- S3 client uses path-style addressing (needed for R2 + test compat)
- CI workflow gains integration test job (stub CSS, no Tailwind needed)
- Makefile: smoke target replaced with integration target

Deleted: test/smoke_test.sh, .github/workflows/smoke-test.yml

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Allow insecure HTTP for composer in integration tests

The httptest server uses plain HTTP (http://127.0.0.1:...) which
Composer's secure-http default blocks. Add secure-http: false to the
generated composer.json config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 00:38:21 -04:00

31 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Capture WordPress.org API fixtures for integration tests.
# Run once to snapshot, commit the results, re-run to refresh.
#
# Usage: ./test/capture-fixtures.sh
#
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
FIXTURE_DIR="${ROOT_DIR}/internal/wporg/testdata"
PLUGINS=(akismet classic-editor contact-form-7)
THEMES=(astra twentytwentyfive)
mkdir -p "${FIXTURE_DIR}/plugins" "${FIXTURE_DIR}/themes"
echo "Capturing plugin fixtures..."
for slug in "${PLUGINS[@]}"; do
echo "${slug}"
curl -sS "https://api.wordpress.org/plugins/info/1.2/?action=plugin_information&request%5Bslug%5D=${slug}&request%5Bfields%5D%5Bversions%5D=true&request%5Bfields%5D%5Bdescription%5D=false&request%5Bfields%5D%5Bsections%5D=false&request%5Bfields%5D%5Bcompatibility%5D=false&request%5Bfields%5D%5Breviews%5D=false&request%5Bfields%5D%5Bbanners%5D=false&request%5Bfields%5D%5Bicons%5D=false&request%5Bfields%5D%5Bdonate_link%5D=false&request%5Bfields%5D%5Bratings%5D=false&request%5Bfields%5D%5Bcontributors%5D=false&request%5Bfields%5D%5Btags%5D=false&request%5Bfields%5D%5Bactive_installs%5D=true&request%5Bfields%5D%5Brequires%5D=true&request%5Bfields%5D%5Btested%5D=true&request%5Bfields%5D%5Brequires_php%5D=true&request%5Bfields%5D%5Bauthor%5D=true&request%5Bfields%5D%5Bshort_description%5D=true&request%5Bfields%5D%5Bhomepage%5D=true&request%5Bfields%5D%5Blast_updated%5D=true&request%5Bfields%5D%5Badded%5D=true&request%5Bfields%5D%5Bdownload_link%5D=true" | python3 -m json.tool > "${FIXTURE_DIR}/plugins/${slug}.json"
done
echo "Capturing theme fixtures..."
for slug in "${THEMES[@]}"; do
echo "${slug}"
curl -sS "https://api.wordpress.org/themes/info/1.2/?action=theme_information&request%5Bslug%5D=${slug}&request%5Bfields%5D%5Bversions%5D=true&request%5Bfields%5D%5Bactive_installs%5D=true&request%5Bfields%5D%5Bsections%5D=true&request%5Bfields%5D%5Bauthor%5D=true&request%5Bfields%5D%5Bhomepage%5D=true&request%5Bfields%5D%5Blast_updated%5D=true" | python3 -m json.tool > "${FIXTURE_DIR}/themes/${slug}.json"
done
echo "Done. Fixtures written to ${FIXTURE_DIR}"