fix(tests): use count flag to check example errors
This commit is contained in:
parent
e05d429164
commit
d2156a5b23
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue