#!/usr/bin/env bash
# Find test file(s) for a plugin.
# Usage: test-for-plugin _plugins/src/infrastructure/url_utils.rb

set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/lib/common.sh"

if [[ $# -eq 0 ]]; then
    echo "Usage: $(basename "$0") <plugin-path>" >&2
    echo "Example: $(basename "$0") _plugins/src/infrastructure/url_utils.rb" >&2
    exit 1
fi

plugin_path="${1#./}"

if [[ ! "$plugin_path" =~ ^$PLUGINS_DIR/ ]]; then
    echo "Error: Path must be under $PLUGINS_DIR/" >&2
    exit 1
fi

if ! find_tests_for_plugin "$plugin_path"; then
    echo "MISSING"
    exit 1
fi
