23 lines
783 B
Bash
23 lines
783 B
Bash
#!/usr/bin/env bats
|
|
|
|
load '../posodobi_blog.sh' # Load the script to be tested
|
|
|
|
@test "check_jq_dependency exits with error if jq is not installed" {
|
|
# Mock command -v jq to simulate jq not being installed
|
|
PATH_ORIGINAL="$PATH"
|
|
export PATH="/tmp/nonexistent_path:$PATH" # Temporarily modify PATH
|
|
|
|
run check_jq_dependency
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"Error: 'jq' is not installed. Please install it to run this script."* ]]
|
|
|
|
export PATH="$PATH_ORIGINAL" # Restore original PATH
|
|
}
|
|
|
|
@test "check_jq_dependency does not exit if jq is installed" {
|
|
# Mock command -v jq to simulate jq being installed
|
|
# Assuming jq is installed in the test environment
|
|
run check_jq_dependency
|
|
[ "$status" -eq 0 ]
|
|
[ "$output" == "" ] # Should not print anything on success
|
|
} |