feat(test): start adding pragma-based tests to examples
This commit is contained in:
parent
15933ba620
commit
0c7d4428a3
|
@ -1,5 +1,8 @@
|
||||||
|
# test exit-status 0
|
||||||
|
|
||||||
metadata:
|
metadata:
|
||||||
name: example
|
name: example
|
||||||
|
labels: {}
|
||||||
spec:
|
spec:
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
# for each file in examples
|
||||||
|
EXAMPLES="$(find examples -name '*.yml')"
|
||||||
|
|
||||||
|
while read -r example;
|
||||||
|
do
|
||||||
|
EXPECTED_STATUS="$(grep '# test exit-status' "${example}" | sed 's/# test exit-status \([0-9]*\)/\1/')"
|
||||||
|
|
||||||
|
echo "Testing: ${example} (should be ${EXPECTED_STATUS})"
|
||||||
|
|
||||||
|
node out/index.js --rules rules/kubernetes.yml --tag kubernetes --source ${example}
|
||||||
|
|
||||||
|
ACTUAL_STATUS=$?
|
||||||
|
|
||||||
|
if [[ ${ACTUAL_STATUS} != ${EXPECTED_STATUS} ]];
|
||||||
|
then
|
||||||
|
echo "Status does not match!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done <<< "${EXAMPLES}"
|
||||||
|
# read pragmas:
|
||||||
|
# rules
|
||||||
|
# tags
|
||||||
|
|
||||||
|
# run
|
Loading…
Reference in New Issue