-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07e31c5
commit 6b0a401
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bats | ||
|
||
function setup() { | ||
load "$HOME/Developments/SmartGic/shell-test/test_helper/bats-support/load" | ||
load "$HOME/Developments/SmartGic/shell-test/test_helper/bats-assert/load" | ||
load ../../utils/constants.sh | ||
load ../../utils/common.sh | ||
LOG_FILE=/tmp/ovos-installer.log | ||
} | ||
|
||
@test "function_delete_log_if_exist" { | ||
run touch "$LOG_FILE" | ||
run delete_log | ||
assert_success | ||
} | ||
|
||
@test "function_delete_log_non_exist" { | ||
run delete_log | ||
assert_success | ||
} | ||
|
||
@test "function_delete_log_fail" { | ||
LOG_FILE=/var/log/ovos-installer.log | ||
run delete_log | ||
assert_failure | ||
} | ||
|
||
@test "function_detect_user_root" { | ||
USER_ID=0 | ||
run detect_user | ||
assert_success | ||
} | ||
|
||
@test "function_detect_user_non_root" { | ||
run detect_user | ||
assert_output --partial "This script must be run as root or with sudo" | ||
} | ||
|
||
@test "function_detect_cpu_instructions_capable" { | ||
function grep() { | ||
return 0 | ||
} | ||
export -f grep | ||
detect_cpu_instructions | ||
echo $CPU_IS_CAPABLE | ||
[ "${CPU_IS_CAPABLE}" == "true" ] | ||
unset grep | ||
} | ||
|
||
@test "function_detect_cpu_instructions_not_capable" { | ||
function grep() { | ||
return 1 | ||
} | ||
export -f grep | ||
detect_cpu_instructions | ||
echo $CPU_IS_CAPABLE | ||
[ "${CPU_IS_CAPABLE}" == "false" ] | ||
unset grep | ||
} |