diff --git a/Makefile b/Makefile index f292314..bcac57f 100755 --- a/Makefile +++ b/Makefile @@ -87,9 +87,15 @@ build-bundle: node_modules build-image: build-bundle docker build $(ROOT_PATH) -test: build-bundle +test: test-mocha test-examples + +test-mocha: ## run small (unit) tests +test-mocha: build-bundle $(NODE_BIN)/mocha $(TARGET_PATH)/test.js +test-examples: ## run medium (feature) tests + $(SCRIPT_PATH)/test-examples.sh + yarn-install: ## install dependencies from package and lock file yarn diff --git a/examples/kubernetes-resources-low.yml b/examples/kubernetes-resources-low.yml index e0e0edf..288e2b1 100644 --- a/examples/kubernetes-resources-low.yml +++ b/examples/kubernetes-resources-low.yml @@ -1,5 +1,10 @@ +# test rules kubernetes +# test tags kubernetes +# test exit-status 1 + metadata: name: example + labels: {} spec: template: spec: diff --git a/examples/kubernetes-resources-med.yml b/examples/kubernetes-resources-med.yml index 58f8b4f..6bdf2cb 100644 --- a/examples/kubernetes-resources-med.yml +++ b/examples/kubernetes-resources-med.yml @@ -1,5 +1,10 @@ +# test rules kubernetes +# test tags kubernetes +# test exit-status 0 + metadata: name: example + labels: {} spec: template: spec: diff --git a/examples/kubernetes-resources-none.yml b/examples/kubernetes-resources-none.yml index 7ae0ab3..c5d5387 100644 --- a/examples/kubernetes-resources-none.yml +++ b/examples/kubernetes-resources-none.yml @@ -1,3 +1,7 @@ +# test rules kubernetes +# test tags kubernetes +# test exit-status 1 + metadata: name: example spec: diff --git a/examples/kubernetes-resources-some.yml b/examples/kubernetes-resources-some.yml index 660fbe9..97f6f40 100644 --- a/examples/kubernetes-resources-some.yml +++ b/examples/kubernetes-resources-some.yml @@ -1,3 +1,7 @@ +# test rules kubernetes +# test tags kubernetes +# test exit-status 1 + metadata: name: example spec: diff --git a/scripts/test-examples.sh b/scripts/test-examples.sh index fb0eb02..841e9a0 100755 --- a/scripts/test-examples.sh +++ b/scripts/test-examples.sh @@ -1,5 +1,7 @@ -# for each file in examples -EXAMPLES="$(find examples -name '*.yml')" +#! /bin/bash + +EXAMPLES="$(find ./examples -name '*.yml')" +echo "Found examples: ${EXAMPLES}" while read -r example; do @@ -22,7 +24,7 @@ do echo "Expected errors: ${EXPECTED_ERRORS}" echo "Expected status: ${EXPECTED_STATUS}" - node out/index.js --rules rules/${USE_RULES}.yml --tag ${USE_TAGS} --source ${example} + node out/index.js --rules "rules/${USE_RULES}.yml" --tag ${USE_TAGS} --source ${example} ACTUAL_STATUS=$? @@ -32,8 +34,3 @@ do exit 1 fi done <<< "${EXAMPLES}" -# read pragmas: -# rules -# tags - -# run \ No newline at end of file