1
0
Fork 0

feat(test): start adding pragma-based tests to examples

This commit is contained in:
ssube 2019-07-01 07:50:34 -05:00
parent 15933ba620
commit 0c7d4428a3
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 27 additions and 0 deletions

View File

@ -1,5 +1,8 @@
# test exit-status 0
metadata:
name: example
labels: {}
spec:
template:
spec:

24
scripts/test-examples.sh Executable file
View File

@ -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