#!/usr/bin/env bash
set -euo pipefail

# Runs integration tests inside the ez-api repo (builds docker-compose + go test).

REPO_ROOT=$(cd -- "$(dirname -- "$0")"/.. && pwd)
compose_file="$REPO_ROOT/docker-compose.integration.yml"

echo "[integration] bringing up services..."
docker compose -f "$compose_file" up --build -d --wait

cleanup() {
  echo "[integration] tearing down services..."
  docker compose -f "$compose_file" down -v
}
trap cleanup EXIT

echo "[integration] running go test with integration tag..."
cd "$REPO_ROOT/test"
go test -tags=integration ./...
