Skip to content

Commit

Permalink
Cleanup temporary files/dirs from tests. (#90)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Linder <linder.gabriel@gmail.com>
  • Loading branch information
dargor authored Mar 24, 2021
1 parent be47fb3 commit 3b64668
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion tests/lib/helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ setup() {
SEED="${RANDOM}"

TEST_TEMP_DIR="$(TMPDIR="${W_TEMP:-/tmp/}" mktemp -d)"
HOME="$(mktemp -d)"
TEST_TEMP_HOME="$(mktemp -d)"
HOME="${TEST_TEMP_HOME}"

# shellcheck disable=SC2034
XDG_DATA_HOME="${HOME}"
Expand Down Expand Up @@ -132,6 +133,7 @@ teardown() {
rm -rf "${TEST_TEMP_DIR}/home/.gnupg/"

temp_del "${TEST_TEMP_DIR}"
temp_del "${TEST_TEMP_HOME}"
}

create_chart() {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/dec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ load '../bats/extensions/bats-file/load'
assert_file_exist "${HELM_SECRETS_DEC_DIR}/secrets.yaml.dec"
assert_file_contains "${HELM_SECRETS_DEC_DIR}/secrets.yaml.dec" 'global_secret: '
assert_file_contains "${HELM_SECRETS_DEC_DIR}/secrets.yaml.dec" 'global_bar'

temp_del "${HELM_SECRETS_DEC_DIR}"
}

@test "dec: Decrypt secrets.yaml + http://" {
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/plugin-install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load '../bats/extensions/bats-assert/load'
load '../bats/extensions/bats-file/load'

@test "plugin-install: helm plugin install" {
HOME="$(mktemp -d)"
HOME="$(mktemp -d "${TEST_TEMP_HOME}/tmp.XXXXXXXXXX")"

# Windows
# See: https://github.com/helm/helm/blob/b4f8312dbaf479e5f772cd17ae3768c7a7bb3832/pkg/helmpath/lazypath_windows.go#L22
Expand All @@ -15,13 +15,15 @@ load '../bats/extensions/bats-file/load'

run helm plugin install "${GIT_ROOT}"
assert_output --regexp "$(printf "sops is already installed: sops .*\nInstalled plugin: secrets")"

HOME="${TEST_TEMP_HOME}"
}

@test "plugin-install: SKIP_SOPS_INSTALL=true helm plugin install" {
SKIP_SOPS_INSTALL=true
export SKIP_SOPS_INSTALL

HOME="$(mktemp -d)"
HOME="$(mktemp -d "${TEST_TEMP_HOME}/tmp.XXXXXXXXXX")"

# Windows
# See: https://github.com/helm/helm/blob/b4f8312dbaf479e5f772cd17ae3768c7a7bb3832/pkg/helmpath/lazypath_windows.go#L22
Expand All @@ -30,6 +32,8 @@ load '../bats/extensions/bats-file/load'

run helm plugin install "${GIT_ROOT}"
assert_output --regexp "$(printf "Skipping sops installation.\nInstalled plugin: secrets")"

HOME="${TEST_TEMP_HOME}"
}

@test "plugin-install: helm plugin list" {
Expand Down

0 comments on commit 3b64668

Please sign in to comment.