Files
troubleshoot/test/validate-preflight-e2e.sh
danj-replicated f692635054 Add stdin and multidoc support to preflight. (#1114)
* add - url keyword for stdin
* add basic multidoc support
* filter on preflight kind
* add e2e test for stdin
2023-04-14 11:21:45 +12:00

46 lines
994 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
tmpdir="$(mktemp -d)"
./bin/preflight --debug --interactive=false --format=json examples/preflight/e2e.yaml > "$tmpdir/result.json"
if [ $? -ne 0 ]; then
echo "preflight command failed"
exit $EXIT_STATUS
fi
cat "$tmpdir/result.json"
EXIT_STATUS=0
if grep -q "was not collected" "$tmpdir/result.json"; then
echo "Some files were not collected"
EXIT_STATUS=1
fi
if (( `jq '.pass | length' "$tmpdir/result.json"` < 1 )); then
echo "No passing preflights found"
EXIT_STATUS=1
fi
if (( `jq '.warn | length' "$tmpdir/result.json"` > 0 )); then
echo "Warnings found"
EXIT_STATUS=1
fi
if (( `jq '.fail | length' "$tmpdir/result.json"` > 0 )); then
echo "Failed preflights found"
EXIT_STATUS=1
fi
# test stdin
cat examples/preflight/e2e.yaml | ./bin/preflight --debug --interactive=false --format=json - > "$tmpdir/result.json"
if [ $? -ne 0 ]; then
echo "preflight command failed"
exit $EXIT_STATUS
fi
rm -rf "$tmpdir"
exit $EXIT_STATUS