Files
troubleshoot/test/validate-preflight-e2e.sh
2022-06-02 13:41:00 +00:00

34 lines
679 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
tmpdir="$(mktemp -d)"
./bin/preflight --interactive=false --format=json examples/preflight/e2e.yaml > "$tmpdir/result.json"
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
rm -rf "$tmpdir"
exit $EXIT_STATUS