Skip to content

Commit

Permalink
[tests] Add more BATS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
goldyfruit committed Nov 20, 2023
1 parent bafa27c commit f33674b
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
28 changes: 28 additions & 0 deletions tests/bats/ansible.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bats

function setup() {
load "$HOME/shell-testing/test_helper/bats-support/load"
load "$HOME/shell-testing/test_helper/bats-assert/load"
load ../../utils/constants.sh
load ../../utils/common.sh
LOG_FILE=/tmp/ovos-installer.log
}

@test "function_install_ansible" {
RUN_AS_HOME=/home/$USER
VENV_PATH="${RUN_AS_HOME}/.venvs/${INSTALLER_VENV_NAME}"
function ansible-galaxy() {
return 0
}
function pip3() {
return 0
}
export -f ansible-galaxy pip3
run install_ansible
assert_success
unset ansible-galaxy pip3
}

function teardown() {
rm -f "$LOG_FILE"
}
2 changes: 1 addition & 1 deletion tests/bats/instance.bats
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function setup() {
}

@test "function_detect_existing_instance_venv_exists" {
RUN_AS_HOME=$USER
RUN_AS_HOME=/home/$USER
run mkdir -p "$RUN_AS_HOME/.venvs/ovos"
function docker() {
return 0
Expand Down
47 changes: 47 additions & 0 deletions tests/bats/virtualenv.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bats

function setup() {
load "$HOME/shell-testing/test_helper/bats-support/load"
load "$HOME/shell-testing/test_helper/bats-assert/load"
load ../../utils/constants.sh
load ../../utils/common.sh
LOG_FILE=/tmp/ovos-installer.log
}

@test "function_create_python_venv_exists" {
RUN_AS_HOME=/home/$USER
VENV_PATH="${RUN_AS_HOME}/.venvs/${INSTALLER_VENV_NAME}"
function source() {
return 0
}
function pip3() {
return 0
}
export -f source pip3
run mkdir -p "$VENV_PATH"
run create_python_venv
assert_success
unset source pip3
}

@test "function_create_python_venv_not_exists" {
RUN_AS_HOME=/home/$USER
VENV_PATH="${RUN_AS_HOME}/.venvs/${INSTALLER_VENV_NAME}"
function python3() {
return 0
}
function source() {
return 0
}
function pip3() {
return 0
}
export -f python3 source pip3
run create_python_venv
assert_success
unset python3 source pip3
}

function teardown() {
rm -f "$LOG_FILE"
}

0 comments on commit f33674b

Please sign in to comment.