fix: add checks and handle errors brew-bump.sh
feat(script): add steps-lib, is_env_var_set & test feat(brew-bump): add check for VERSION feat(brew-bump): check HOMEBREW_GITHUB_API_TOKEN feat(steps-lib): add directory_exists helper fn fix(brew-bump): check that git clone worked feat(brew-bump): add check for remote upstream fix: remove upstream command thing feat(steps-lib): add file_exists helper function feat(brew-bump): add check for git-askpass.sh feat(steps-lib): add is_executable function & test feat(brew-bump): add check for is_executable refactor: use GIT_ASKPASS as variable
This commit is contained in:
46
test/scripts/steps-lib.bats
Normal file
46
test/scripts/steps-lib.bats
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
SCRIPT_NAME="steps-lib.sh"
|
||||
SCRIPT="$BATS_TEST_DIRNAME/../../ci/steps/$SCRIPT_NAME"
|
||||
|
||||
source "$SCRIPT"
|
||||
|
||||
@test "is_env_var_set should return 1 if env var is not set" {
|
||||
run is_env_var_set "ASDF_TEST_SET"
|
||||
[ "$output" = 1 ]
|
||||
}
|
||||
|
||||
@test "is_env_var_set should return 0 if env var is set" {
|
||||
ASDF_TEST_SET="test" run is_env_var_set "ASDF_TEST_SET"
|
||||
[ "$output" = 0 ]
|
||||
}
|
||||
|
||||
@test "directory_exists should 1 if directory doesn't exist" {
|
||||
run directory_exists "/tmp/asdfasdfasdf"
|
||||
[ "$output" = 1 ]
|
||||
}
|
||||
|
||||
@test "directory_exists should 0 if directory exists" {
|
||||
run directory_exists "$(pwd)"
|
||||
[ "$output" = 0 ]
|
||||
}
|
||||
|
||||
@test "file_exists should 1 if file doesn't exist" {
|
||||
run file_exists "hello-asfd.sh"
|
||||
[ "$output" = 1 ]
|
||||
}
|
||||
|
||||
@test "file_exists should 0 if file exists" {
|
||||
run file_exists "$SCRIPT"
|
||||
[ "$output" = 0 ]
|
||||
}
|
||||
|
||||
@test "is_executable should 1 if file isn't executable" {
|
||||
run is_executable "hello-asfd.sh"
|
||||
[ "$output" = 1 ]
|
||||
}
|
||||
|
||||
@test "is_executable should 0 if file is executable" {
|
||||
run is_executable "$SCRIPT"
|
||||
[ "$output" = 0 ]
|
||||
}
|
Reference in New Issue
Block a user