#!/bin/bash
set -eou pipefail
case "${1:-dev}" in
dev) docker compose up -d --wait && docker compose exec test go test "${@:2}" ;;
ci) docker compose run --rm test go test "${@:2}" ;;
*)
  echo "Usage: $0 [dev|ci] [go test arguments...]"
  echo
  echo "Commands:"
  echo "    dev    Start services and run tests in the existing test container (default)."
  echo "    ci     Execute tests in a new, one-off container and clean up."
  echo
  echo "Examples:"
  echo "    $0 dev ./... -v"
  echo "    $0 ci -run TestSpecificFunction"
  exit 1
  ;;
esac
