Skip to content
Merged
2 changes: 1 addition & 1 deletion .vortex/tooling/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "Packages used for testing the drevops/vortex-tooling shell scripts.",
"license": "GPL-3.0-or-later",
"devDependencies": {
"bats-helpers": "npm:@drevops/bats-helpers@^1.5.1"
"bats-helpers": "npm:@drevops/bats-helpers@^2.0"
}
}
14 changes: 7 additions & 7 deletions .vortex/tooling/tests/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ setup() {
export BATS_LIB_PATH="${ROOT_DIR}/.vortex/tooling/node_modules"

# Load 'bats-helpers' library.
ASSERT_DIR_EXCLUDE=("vortex" ".data")
export ASSERT_DIR_EXCLUDE
BATS_HELPERS_ASSERT_DIR_EXCLUDE=("vortex" ".data")
export BATS_HELPERS_ASSERT_DIR_EXCLUDE
bats_load_library bats-helpers

# Setup command mocking.
setup_mock
mock_setup

# Isolate the SSH agent from tests. Scripts under test call `ssh-add`, which
# reaches the agent via the inherited SSH_AUTH_SOCK - a socket the HOME
# override does not sandbox. Stub `ssh-add` (the only agent-mutating command)
# so a test can never read, pollute or, with VORTEX_SSH_REMOVE_ALL_KEYS=1,
# wipe the real agent of the developer running the suite. Tests that assert
# specific `ssh-add` calls override this with their own mock via run_steps.
# specific `ssh-add` calls override this with their own mock via steps_run.
mock_command "ssh-add" >/dev/null

##
Expand Down Expand Up @@ -175,7 +175,7 @@ setup() {
if [ "${BATS_VERBOSE_RUN:-}" = "1" ] || [ "${TEST_VORTEX_DEBUG:-}" = "1" ]; then
echo "Verbose run enabled." >&3
echo "BUILD_DIR: ${BUILD_DIR}" >&3
export RUN_STEPS_DEBUG=1
export BATS_HELPERS_STEPS_DEBUG=1
fi

# Change directory to the current project directory for each test. Tests
Expand All @@ -201,7 +201,7 @@ fixture_local_repo() {

if [ "${do_copy_code:-}" -eq 1 ]; then
fixture_prepare_dir "${dir}"
export BATS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
export BATS_HELPERS_FIXTURE_EXPORT_CODEBASE_ENABLED=1
fixture_export_codebase "${dir}" "${ROOT_DIR}"
fi

Expand Down Expand Up @@ -333,7 +333,7 @@ git_init() {
local allow_receive_update="${1:-0}"
local dir="${2:-$(pwd)}"

assert_not_git_repo "${dir}"
assert_git_not_repo "${dir}"
git --work-tree="${dir}" --git-dir="${dir}/.git" init >/dev/null

if [ "${allow_receive_update:-}" -eq 1 ]; then
Expand Down
12 changes: 6 additions & 6 deletions .vortex/tooling/tests/unit/deploy-artifact.bats
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ load ../_helper.bash
"SHA256 checksum verification failed for git-artifact binary."
"- Finished artifact deployment."
)
mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-artifact
assert_failure

run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -153,7 +153,7 @@ load ../_helper.bash
"Running artifact builder."
"Finished artifact deployment."
)
mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-artifact
assert_success
Expand All @@ -162,7 +162,7 @@ load ../_helper.bash
assert_output_not_contains "--cleanup-pattern"
assert_output_not_contains "--cleanup-age"

run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"
assert_equal "2" "$(mock_get_call_num "${mock_realpath}" 1)"

popd >/dev/null
Expand Down Expand Up @@ -204,7 +204,7 @@ load ../_helper.bash
"Running artifact builder."
"Finished artifact deployment."
)
mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-artifact
assert_success
Expand All @@ -213,7 +213,7 @@ load ../_helper.bash
assert_output_contains "--cleanup-pattern=feature/*,bugfix/*"
assert_output_contains "--cleanup-age=3"

run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
64 changes: 32 additions & 32 deletions .vortex/tooling/tests/unit/deploy-lagoon.bats
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -123,11 +123,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -173,13 +173,13 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

# Mock commands are handled by the steps

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -212,13 +212,13 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

# Mock commands are handled by the steps

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -257,13 +257,13 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

# Mock commands are handled by the steps

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -312,12 +312,12 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

# Mock commands are handled by the steps
run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -345,13 +345,13 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

# Mock commands are handled by the steps

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -387,11 +387,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -427,11 +427,11 @@ load ../_helper.bash
"would exceed the configured limit"
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_failure
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -470,11 +470,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand All @@ -499,11 +499,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -531,11 +531,11 @@ load ../_helper.bash
"[FAIL] Lagoon deployment completed with errors."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_failure
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -564,11 +564,11 @@ load ../_helper.bash
"Error: deployment rejected by policy."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_failure
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand Down Expand Up @@ -604,11 +604,11 @@ load ../_helper.bash
"Error: deployment rejected by policy."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_failure
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand All @@ -631,11 +631,11 @@ load ../_helper.bash
"[FAIL] Lagoon deployment completed with errors."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_failure
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Expand All @@ -660,11 +660,11 @@ load ../_helper.bash
"Finished Lagoon deployment."
)

mocks="$(run_steps "setup")"
mocks="$(steps_run "setup")"

run .vortex/tooling/src/vortex-deploy-lagoon
assert_success
run_steps "assert" "${mocks[@]}"
steps_run "assert" "${mocks[@]}"

popd >/dev/null
}
Loading