Skip to content

Commit

Permalink
Create deployment profile library for BATS
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <[email protected]>
  • Loading branch information
jandubois committed Jul 7, 2023
1 parent 24f14e6 commit b6a0f96
Show file tree
Hide file tree
Showing 7 changed files with 551 additions and 42 deletions.
16 changes: 0 additions & 16 deletions bats/tests/containers/factory-reset.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load '../helpers/load'
assert=assert
refute=refute

@test 'factory reset' {
factory_reset
Expand Down Expand Up @@ -156,20 +154,6 @@ rdctl_factory_reset() {
fi
}

refute_failure() {
assert_success
}

refute_not_exists() {
assert_exists "$@"
}

before() {
assert=refute
refute=assert
"$@"
}

check_directories() {
# Check if all expected directories are created after starting application/ are deleted after a factory reset
delete_dir=("$PATH_APP_HOME" "$PATH_CONFIG")
Expand Down
19 changes: 19 additions & 0 deletions bats/tests/helpers/defaults.bash
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,28 @@ using_ghcr_images() {
is_true "$RD_USE_GHCR_IMAGES"
}

########################################################################
: "${RD_DELETE_PROFILES:=true}"

deleting_profiles() {
is_true "$RD_DELETE_PROFILES"
}

########################################################################
: "${RD_USE_IMAGE_ALLOW_LIST:=false}"

using_image_allow_list() {
is_true "$RD_USE_IMAGE_ALLOW_LIST"
}

########################################################################
# RD_USE_PROFILE is for internal use. It uses a profile instead of
# settings.json to set initial values for WSL integrations and allowed
# images list because when settings.json exists the default profile is
# ignored.

: "${RD_USE_PROFILE:=false}"

########################################################################
: "${RD_USE_VZ_EMULATION:=false}"

Expand Down Expand Up @@ -126,6 +141,10 @@ validate_enum RD_9P_PROTOCOL_VERSION 9p2000 9p2000.u 9p2000.L

validate_enum RD_9P_SECURITY_MODEL passthrough mapped-xattr mapped-file none

########################################################################
# Use RD_PROTECTED_DOT in profile settings for WSL distro names
: "${RD_PROTECTED_DOT:=·}"

########################################################################
# RD_LOCATION specifies the location where Rancher Desktop is installed
# system: default system-wide install location shared for all users
Expand Down
13 changes: 8 additions & 5 deletions bats/tests/helpers/load.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ source "$PATH_BATS_HELPERS/paths.bash"
# and PATH_* variables from paths.bash
source "$PATH_BATS_HELPERS/commands.bash"

# profile.bash uses is_xxx() from os.bash
source "$PATH_BATS_HELPERS/profile.bash"

# vm.bash uses various PATH_* variables from paths.bash,
# rdctl from commands.bash, and jq_output from utils.bash
source "$PATH_BATS_HELPERS/vm.bash"
Expand Down Expand Up @@ -74,14 +77,14 @@ setup_file() {
}

teardown_file() {
call_local_function

capture_logs

# On Linux & Windows if we don't shutdown Rancher Desktop bats test don't terminate
# On Linux & Windows if we don't shutdown Rancher Desktop bats tests don't terminate
if is_linux || is_windows; then
run rdctl shutdown
fi

call_local_function
}

setup() {
Expand All @@ -95,9 +98,9 @@ setup() {
}

teardown() {
call_local_function

if [ -z "$BATS_TEST_SKIPPED" ] && [ -z "$BATS_TEST_COMPLETED" ]; then
take_screenshot
fi

call_local_function
}
Loading

0 comments on commit b6a0f96

Please sign in to comment.