Probes Anthropic OAuth and MiniMax subscription usage and displays percentage consumed for 5-hour and 7-day windows with colour-coded output. Ported probe logic from agent-runtimes/scripts/ralph_code.
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SCRIPT="$SCRIPT_DIR/../scripts/agent-subscriptions"
|
|
|
|
GREEN='\033[32m'; RED='\033[31m'; RESET='\033[0m'
|
|
pass() { echo -e "${GREEN}PASS${RESET}: $1"; }
|
|
fail() { echo -e "${RED}FAIL${RESET}: $1"; FAILURES=$((FAILURES + 1)); }
|
|
FAILURES=0
|
|
|
|
# --dryrun: exits 0
|
|
output=$("$SCRIPT" --dryrun 2>&1)
|
|
code=$?
|
|
[[ $code -eq 0 ]] && pass "--dryrun exits 0" || fail "--dryrun exits 0 (got $code)"
|
|
|
|
# --dryrun: mentions Anthropic
|
|
echo "$output" | grep -qi "Anthropic" && pass "--dryrun mentions Anthropic" || fail "--dryrun mentions Anthropic"
|
|
|
|
# --dryrun: mentions MiniMax
|
|
echo "$output" | grep -qi "MiniMax" && pass "--dryrun mentions MiniMax" || fail "--dryrun mentions MiniMax"
|
|
|
|
# --dryrun: shows probe URL for Anthropic
|
|
echo "$output" | grep -q "api.anthropic.com" && pass "--dryrun shows Anthropic URL" || fail "--dryrun shows Anthropic URL"
|
|
|
|
# --dryrun: shows probe URL for MiniMax
|
|
echo "$output" | grep -q "minimax.io" && pass "--dryrun shows MiniMax URL" || fail "--dryrun shows MiniMax URL"
|
|
|
|
# --dryrun: mentions SOPS
|
|
echo "$output" | grep -qi "SOPS\|sops" && pass "--dryrun mentions SOPS" || fail "--dryrun mentions SOPS"
|
|
|
|
# -n (short flag): exits 0
|
|
"$SCRIPT" -n >/dev/null 2>&1
|
|
code=$?
|
|
[[ $code -eq 0 ]] && pass "-n exits 0" || fail "-n exits 0 (got $code)"
|
|
|
|
# --help: exits 0
|
|
"$SCRIPT" --help >/dev/null 2>&1
|
|
code=$?
|
|
[[ $code -eq 0 ]] && pass "--help exits 0" || fail "--help exits 0 (got $code)"
|
|
|
|
# --help: mentions dryrun
|
|
help_out=$("$SCRIPT" --help 2>&1)
|
|
echo "$help_out" | grep -q "\-\-dryrun\|-n" && pass "--help documents dryrun" || fail "--help documents dryrun"
|
|
|
|
# Unknown flag: exits non-zero
|
|
"$SCRIPT" --bogus-flag >/dev/null 2>&1
|
|
code=$?
|
|
[[ $code -ne 0 ]] && pass "unknown flag exits non-zero" || fail "unknown flag exits non-zero (got 0)"
|
|
|
|
echo
|
|
if [[ $FAILURES -eq 0 ]]; then
|
|
echo -e "${GREEN}All tests passed.${RESET}"
|
|
exit 0
|
|
else
|
|
echo -e "${RED}$FAILURES test(s) failed.${RESET}"
|
|
exit 1
|
|
fi
|