#!/usr/bin/env bash
# Run pytest for all Lambda functions. Pass additional pytest args directly,
# e.g.:  ./scripts/test.sh -k test_resolve_gp --cov=src
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

LAMBDAS=(
    "connect-shopify-stores"
    "onboard-shopify-stores"
    "sync-shopify-data-connectors"
)

FAILED=()

for lambda in "${LAMBDAS[@]}"; do
    echo "=== $lambda ==="
    if ! (cd "$REPO_ROOT/lambda/$lambda" && uv run pytest "$@"); then
        FAILED+=("$lambda")
    fi
done

if [[ ${#FAILED[@]} -gt 0 ]]; then
    echo ""
    echo "FAILED: ${FAILED[*]}"
    exit 1
fi
