diff --git a/tests/bats/display.bats b/tests/bats/display.bats index cfcf9d82..e7d8f508 100644 --- a/tests/bats/display.bats +++ b/tests/bats/display.bats @@ -11,24 +11,22 @@ function setup() { @test "function_detect_display_x11" { function loginctl() { echo "x11" - } + } sessions="3" export -f loginctl detect_display - echo $DISPLAY_SERVER - [ "$DISPLAY_SERVER" == "x11" ] + assert_equal "$DISPLAY_SERVER" "x11" unset loginctl } @test "function_detect_display_wayland" { function loginctl() { echo "wayland" - } + } sessions="6" export -f loginctl detect_display - echo $DISPLAY_SERVER - [ "$DISPLAY_SERVER" == "wayland" ] + assert_equal "$DISPLAY_SERVER" "wayland" unset loginctl } @@ -36,11 +34,10 @@ function setup() { @test "function_detect_display_no_display" { function loginctl() { echo "tty" - } + } sessions="11" export -f loginctl detect_display - echo $DISPLAY_SERVER - [ "$DISPLAY_SERVER" == "N/A" ] + assert_equal "$DISPLAY_SERVER" "N/A" unset loginctl -} \ No newline at end of file +} diff --git a/tests/bats/instance.bats b/tests/bats/instance.bats index 8dfa6046..99cc988a 100644 --- a/tests/bats/instance.bats +++ b/tests/bats/instance.bats @@ -14,8 +14,7 @@ function setup() { } export -f docker detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "true" ] + assert_equal "$EXISTING_INSTANCE" "true" unset docker } @@ -25,8 +24,7 @@ function setup() { } export -f docker detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "false" ] + assert_equal "$EXISTING_INSTANCE" "false" unset docker } @@ -39,8 +37,7 @@ function setup() { } export -f docker podman detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "true" ] + assert_equal "$EXISTING_INSTANCE" "true" unset docker podman } @@ -53,8 +50,7 @@ function setup() { } export -f docker podman detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "false" ] + assert_equal "$EXISTING_INSTANCE" "false" unset docker podman } @@ -69,9 +65,8 @@ function setup() { } export -f docker podman detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "true" ] - unset docker podman + assert_equal "$EXISTING_INSTANCE" "true" + unset docker podman } @test "function_detect_existing_instance_venv_non_exists" { @@ -83,7 +78,6 @@ function setup() { } export -f docker podman detect_existing_instance - echo "$EXISTING_INSTANCE" - [ "$EXISTING_INSTANCE" == "false" ] + assert_equal "$EXISTING_INSTANCE" "false" unset docker podman -} \ No newline at end of file +} diff --git a/tests/bats/main.bats b/tests/bats/main.bats index 85d84590..4d0c287f 100644 --- a/tests/bats/main.bats +++ b/tests/bats/main.bats @@ -8,6 +8,12 @@ function setup() { LOG_FILE=/tmp/ovos-installer.log } +@test "function_on_error_detected" { + run on_error + assert_failure + assert_output --partial "Please check $LOG_FILE for more details" +} + @test "function_delete_log_if_exist" { run touch "$LOG_FILE" run delete_log @@ -20,13 +26,14 @@ function setup() { } @test "function_detect_user_root" { - USER_ID=0 + USER_ID="0" run detect_user assert_success } @test "function_detect_user_non_root" { run detect_user + assert_failure assert_output --partial "This script must be run as root or with sudo" } @@ -36,8 +43,7 @@ function setup() { } export -f grep detect_cpu_instructions - echo "$CPU_IS_CAPABLE" - [ "$CPU_IS_CAPABLE" == "true" ] + assert_equal "$CPU_IS_CAPABLE" "true" unset grep } @@ -47,8 +53,6 @@ function setup() { } export -f grep detect_cpu_instructions - echo "$CPU_IS_CAPABLE" - [ "$CPU_IS_CAPABLE" == "false" ] + assert_equal "$CPU_IS_CAPABLE" "false" unset grep } - diff --git a/tests/bats/sound.bats b/tests/bats/sound.bats index 973ee650..67ecda99 100644 --- a/tests/bats/sound.bats +++ b/tests/bats/sound.bats @@ -20,8 +20,7 @@ function setup() { } export -f pgrep command pactl detect_sound - echo "$SOUND_SERVER" - [ "$SOUND_SERVER" == "pulseaudio" ] + assert_equal "$SOUND_SERVER" "pulseaudio" unset pgrep command pactl } @@ -34,8 +33,7 @@ function setup() { } export -f pgrep command detect_sound - echo "$SOUND_SERVER" - [ "$SOUND_SERVER" == "PulseAudio (on PipeWire)" ] + assert_equal "$SOUND_SERVER" "PulseAudio (on PipeWire)" unset pgrep command } @@ -45,8 +43,7 @@ function setup() { } export -f pgrep detect_sound - echo "$SOUND_SERVER" - [ "$SOUND_SERVER" == "PipeWire" ] + assert_equal "$SOUND_SERVER" "PipeWire" unset pgrep } @@ -57,7 +54,6 @@ function setup() { } export -f pgrep detect_sound - echo "$SOUND_SERVER" - [ "$SOUND_SERVER" == "N/A" ] + assert_equal "$SOUND_SERVER" "N/A" unset pgrep -} \ No newline at end of file +}