#!/usr/bin/env bash # # hub-test.sh - run the Hub unit and round-trip tests. # # The tests use the fake /ask project. They need no network and no secrets. # They run in the golang container so the host does not need a Go toolchain. # # Usage: # scripts/hub-test.sh # run all tests # scripts/hub-test.sh -race # extra args go to "go test" # set -euo pipefail readonly SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" readonly PROJECT_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)" readonly GO_IMAGE="${HUB_GO_IMAGE:-golang:1.25-alpine}" command -v docker >/dev/null 2>&1 || { echo "error: docker is required" >&2; exit 1; } # The mount is read-only so a test run can never change the source tree. docker run --rm \ -v "$PROJECT_DIR/src":/src:ro \ -w /src \ "$GO_IMAGE" \ go test "$@" ./...