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 rules kubernetes
|
||||||
# test tags kubernetes
|
# test tags kubernetes
|
||||||
# test exit-status 1
|
# test exit-status 2
|
||||||
|
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
|
# missing labels
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# test rules kubernetes
|
# test rules kubernetes
|
||||||
# test tags kubernetes
|
# test tags kubernetes
|
||||||
# test exit-status 1
|
# test exit-status 2
|
||||||
|
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
|
labels: {}
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
|
@ -21,6 +22,7 @@ spec:
|
||||||
|
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
|
labels: {}
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
|
@ -29,10 +31,8 @@ spec:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 200m
|
cpu: 200m
|
||||||
memory: 5Mi
|
|
||||||
requests:
|
requests:
|
||||||
cpu: 100m
|
cpu: 100m
|
||||||
memory: 2Mi
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -12,20 +12,17 @@ do
|
||||||
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
|
USE_TAGS="$(grep '# test tags' "${example}" | sed 's/# test tags \(.*\)/\1/')"
|
||||||
[ -z "${USE_TAGS}" ] && echo "Test example must have '# test tags' pragma" && exit 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/')"
|
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
|
||||||
[ -z "${EXPECTED_STATUS}" ] && EXPECTED_STATUS=0
|
[ -z "${EXPECTED_STATUS}" ] && EXPECTED_STATUS=0
|
||||||
|
|
||||||
echo "Using rules: ${USE_RULES}"
|
echo "Using rules: ${USE_RULES}"
|
||||||
echo "Using tags: ${USE_TAGS}"
|
echo "Using tags: ${USE_TAGS}"
|
||||||
echo "Expected errors: ${EXPECTED_ERRORS}"
|
|
||||||
echo "Expected status: ${EXPECTED_STATUS}"
|
echo "Expected status: ${EXPECTED_STATUS}"
|
||||||
|
|
||||||
node out/index.js \
|
node out/index.js \
|
||||||
--config-path ./docs \
|
--config-path ./docs \
|
||||||
--config-name config-stderr.yml \
|
--config-name config-stderr.yml \
|
||||||
|
--count \
|
||||||
--rules "rules/${USE_RULES}.yml" \
|
--rules "rules/${USE_RULES}.yml" \
|
||||||
--tag "${USE_TAGS}" \
|
--tag "${USE_TAGS}" \
|
||||||
--source "${example}"
|
--source "${example}"
|
||||||
|
@ -37,6 +34,7 @@ do
|
||||||
if [ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ];
|
if [ "${ACTUAL_STATUS}" != "${EXPECTED_STATUS}" ];
|
||||||
then
|
then
|
||||||
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
|
echo "Exit status does not match! (expected ${EXPECTED_STATUS}, got ${ACTUAL_STATUS})"
|
||||||
|
echo "Failed in: ${example}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue