Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
workdir="$(mktemp -d)"
|
||||
trap 'rm -rf "$workdir"' EXIT
|
||||
|
||||
cat >"$workdir/.env" <<'EOF'
|
||||
SHX_URL=https://shx.example
|
||||
SHX_TOKEN=test-token
|
||||
EOF
|
||||
|
||||
mkdir -p "$workdir/bin"
|
||||
cat >"$workdir/bin/curl" <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
printf '%s\n' '{"files":["https://shx.example/mock-file"]}'
|
||||
EOF
|
||||
chmod +x "$workdir/bin/curl"
|
||||
|
||||
cat >"$workdir/bin/jq" <<'EOF'
|
||||
#!/usr/bin/env python3
|
||||
import json, sys
|
||||
payload = json.load(sys.stdin)
|
||||
for item in payload.get("files", []):
|
||||
print(item)
|
||||
EOF
|
||||
chmod +x "$workdir/bin/jq"
|
||||
|
||||
touch "$workdir/demo.txt"
|
||||
|
||||
PATH="$workdir/bin:$PATH" \
|
||||
SHX_ENV_FILE="$workdir/.env" \
|
||||
"$repo_root/bin/shx-upload" "$workdir/demo.txt" >"$workdir/out.txt"
|
||||
|
||||
grep -Fx 'https://shx.example/mock-file' "$workdir/out.txt"
|
||||
|
||||
echo 'smoke ok'
|
||||
Reference in New Issue
Block a user