backup-utils/test/bin/curl

23 строки
485 B
Bash
Executable File

#!/usr/bin/env bash
# Usage: curl ...
# Fake curl command stub for tests.
set -e
# Return empty list of indexes for ghe-backup-es-audit-log
if echo "$@" | grep -q '_cat/indices/'; then
exit 0
# Exit with non-zero code to mimic a non-existant index
elif echo "$@" | grep -q 'localhost:9201/audit_log'; then
exit 1
fi
# Write args to stdout
echo "$@"
# Read from stdin and write to stdout when "-d @-" given.
for _ in "$@"; do
if [ "$1" = "@-" ]; then
cat
fi
done