From ae828f75d1bc79ee387b83e3ae536a9344ad53eb Mon Sep 17 00:00:00 2001 From: LeeW Date: Mon, 17 Feb 2025 12:46:15 +0100 Subject: [PATCH] makes tests easy to select --- verify/test.sh | 59 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/verify/test.sh b/verify/test.sh index 6313c1d..67f05be 100755 --- a/verify/test.sh +++ b/verify/test.sh @@ -29,31 +29,44 @@ $( cat .sops.yaml ) EOM mv .sops.yaml.tmp .sops.yaml -# TEST +# TESTCASES # define "fixture" repo_root="$(git rev-parse --show-toplevel)" ->&2 echo -e "# ---\n# TEST: create sops cfg in default dir: ${repo_root}" -set -x -rm "${PWD}/.sops.yaml" || : -# note: fail if for any reason sops config defined at top level; this repo should not have this! -test ! -e "${repo_root}/.sops.yaml" -../bin/update_sops.sh -s "${secrets_file}" > /dev/null 2>&1 -test ! -e "${PWD}/.sops.yaml" -test -e "${repo_root}/.sops.yaml" -set +x -echo "TEST RC: $?" -# teardown -# enmesh: restore, since this particular one is checked in -git checkout "${PWD}/.sops.yaml" -rm "${repo_root}/.sops.yaml" ->&2 echo -e "# ---\n# TEST: create sops cfg in curdir: ${PWD}" -echo "ERROR: failing right now" -rm .sops.yaml -../bin/update_sops.sh -c "${PWD}" -s "${secrets_file}" -test -e "${PWD}/.sops.yaml" -test ! -e "${repo_root}/.sops.yaml" -read -p "next test?" __var +# --- +if [[ 1 -eq 1 ]]; then + >&2 echo -e "# ---\n# TEST: create sops cfg in default dir: ${repo_root}" + set -x + rm "${PWD}/.sops.yaml" || : + # note: fail if for any reason sops config defined at top level; this repo should not have this! + test ! -e "${repo_root}/.sops.yaml" + ../bin/update_sops.sh -s "${secrets_file}" > /dev/null 2>&1 + test ! -e "${PWD}/.sops.yaml" + test -e "${repo_root}/.sops.yaml" + set +x + echo "TEST RC: $?" + # teardown + # enmesh: restore, since this particular one is checked in + git checkout "${PWD}/.sops.yaml" + rm "${repo_root}/.sops.yaml" +else + >&2 echo "# INFO: skipping ...." +fi + +# --- +if [[ 0 -eq 1 ]]; then + >&2 echo -e "# ---\n# TEST: create sops cfg in curdir: ${PWD}" + echo "ERROR: failing right now" + # note: fail if for any reason sops config defined at top level; this repo should not have this! + test ! -e "${repo_root}/.sops.yaml" + rm "${PWD}/.sops.yaml" || : + ../bin/update_sops.sh -c "${PWD}" -s "${secrets_file}" + test -e "${PWD}/.sops.yaml" + test ! -e "${repo_root}/.sops.yaml" + echo $? +else + >&2 echo "# INFO: skipping ...." +fi # --- -echo "TEST SUCCESS" +echo "TESTCASES PASSED" exit 0