1
0
Fork 0

fix(tests): use count flag to check example errors

This commit is contained in:
ssube 2019-11-01 21:26:48 -05:00 committed by Sean Sube
parent e05d429164
commit d2156a5b23
3 changed files with 7 additions and 8 deletions

View File

@ -1,9 +1,10 @@
# test rules kubernetes
# test tags kubernetes
# test exit-status 1
# test exit-status 2
metadata:
name: example
# missing labels
spec:
template:
spec:

View File

@ -1,9 +1,10 @@
# test rules kubernetes
# test tags kubernetes
# test exit-status 1
# test exit-status 2
metadata:
name: example
labels: {}
spec:
template:
spec:
@ -21,6 +22,7 @@ spec:
metadata:
name: example
labels: {}
spec:
template:
spec:
@ -29,10 +31,8 @@ spec:
resources:
limits:
cpu: 200m
memory: 5Mi
requests:
cpu: 100m
memory: 2Mi
---

View File

@ -12,20 +12,17 @@ do
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
[ -z "${USE_TAGS}" ] && echo "Test example must have '# test tags' pragma" && exit 1
EXPECTED_ERRORS="$(grep '# test error-count' "${example}" | sed 's/# test error-count \([0-9]*\)/\1/')"
[ -z "${EXPECTED_ERRORS}" ] && EXPECTED_ERRORS=0
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
[ -z "${EXPECTED_STATUS}" ] && EXPECTED_STATUS=0
echo "Using rules: ${USE_RULES}"
echo "Using tags: ${USE_TAGS}"
echo "Expected errors: ${EXPECTED_ERRORS}"
echo "Expected status: ${EXPECTED_STATUS}"
node out/index.js \
--config-path ./docs \
--config-name config-stderr.yml \
--count \
--rules "rules/${USE_RULES}.yml" \
--tag "${USE_TAGS}" \
--source "${example}"
@ -37,6 +34,7 @@ do
if [ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ];
then
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
echo "Failed in: ${example}"
exit 1
fi
done