Compare commits

...

1 Commits

Author SHA1 Message Date
LeeW 51b526e90c refactor: simplifies test control flow 9 months ago

@ -25,7 +25,7 @@ mv .sops.yaml.tmp .sops.yaml
# define "fixture"
repo_root="$(git rev-parse --show-toplevel)"
# ---
if [[ 1 -eq 1 ]]; then
function fn_test_create_sops_cfg_default(){
>&2 echo -e "# ---\n# TEST: create sops cfg in default dir: ${repo_root}"
set -x
rm "${PWD}/.sops.yaml" || :
@ -39,12 +39,10 @@ if [[ 1 -eq 1 ]]; then
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
rm "${repo_root}/.sops.yaml"
else
>&2 echo "# INFO: skipping ...."
fi
}
# ---
if [[ 1 -eq 1 ]]; then
function fn_test_create_sops_cfg_dir_cwd(){
>&2 echo -e "# ---\n# TEST: create sops cfg in curdir: ${PWD}"
set -x
# note: fail if for any reason sops config defined at top level; this repo should not have this!
@ -59,12 +57,10 @@ if [[ 1 -eq 1 ]]; then
# not necessary, all tracked in git
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
else
>&2 echo "# INFO: skipping ...."
fi
}
# ---
if [[ 1 -eq 1 ]]; then
function fn_test_create_sops_cfg_opts_complex_1(){
>&2 echo -e "# ---\n# TEST: Full Args: specify path to each, also for secrets, mix specified and positional params"
set -x
../bin/update_sops.sh -k "${keys_dir}" -c "${sops_cfg_dir}" -s "${secrets_file}" "${secrets_file}" > /dev/null 2>&1
@ -73,12 +69,10 @@ if [[ 1 -eq 1 ]]; then
# not necessary, all tracked in git
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
else
>&2 echo "# INFO: skipping ...."
fi
}
# ---
if [[ 1 -eq 1 ]]; then
function fn_test_auto_find_secrets_files(){
>&2 echo -e "# ---\n# TEST: auto-find secrets files"
# SETUP
_tmp_mock_secrets_dir='mock_hierarchy'
@ -108,12 +102,10 @@ if [[ 1 -eq 1 ]]; then
rm -rf "${_tmp_mock_secrets_dir}"
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
else
>&2 echo "# INFO: skipping ...."
fi
}
# ---
if [[ 1 -eq 1 ]]; then
function fn_test_expect_error_invalid_file(){
>&2 echo -e "# ---\n# TEST: induce error: invalid file"
# dev note: ':' is a noop operator; could also just temporarily disable strict errors
set -x
@ -123,11 +115,33 @@ if [[ 1 -eq 1 ]]; then
# not necessary, all tracked in git
# enmesh: restore, since this particular one is checked in
git checkout "${PWD}/.sops.yaml" > /dev/null 2>&1
}
if [[ 1 -eq 1 ]]; then
fn_test_create_sops_cfg_default
else
>&2 echo "# INFO: skipping ...."
fi
if [[ 1 -eq 1 ]]; then
fn_test_create_sops_cfg_dir_cwd
else
>&2 echo "# INFO: skipping ...."
fi
if [[ 1 -eq 1 ]]; then
fn_test_create_sops_cfg_opts_complex_1
else
>&2 echo "# INFO: skipping ...."
fi
if [[ 1 -eq 1 ]]; then
fn_test_auto_find_secrets_files
else
>&2 echo "# INFO: skipping ...."
fi
if [[ 1 -eq 1 ]]; then
fn_test_expect_error_invalid_file
else
>&2 echo "# INFO: skipping ...."
fi
# ---
echo "TESTCASES PASSED"
exit 0

Loading…
Cancel
Save