-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace swath of redundant tests with working arg-parse test.
- Loading branch information
Matt Pearson
committed
Dec 16, 2015
1 parent
68a726c
commit a1e762a
Showing
3 changed files
with
78 additions
and
88 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,78 @@ | ||
#!/usr/bin/env bats | ||
|
||
source lib/assert.bash | ||
source deploy.sh --source-only | ||
|
||
setup() { | ||
run mktemp -dt deploy_test.XXXX | ||
assert_success | ||
tmp=$output | ||
pushd "$tmp" >/dev/null | ||
} | ||
|
||
teardown() { | ||
popd >/dev/null | ||
rm -rf "$tmp" | ||
} | ||
|
||
set_env_vars() { | ||
# Set environment variables. | ||
export GIT_DEPLOY_USERNAME=env-username | ||
export GIT_DEPLOY_EMAIL=env-email | ||
export GIT_DEPLOY_APPEND_HASH=env-var | ||
} | ||
|
||
write_env_file() { | ||
# Write a '.env' file to override environment variables. | ||
cat <<-EOF > .env | ||
GIT_DEPLOY_EMAIL=dotenv-email | ||
GIT_DEPLOY_APPEND_HASH=env-file | ||
EOF | ||
} | ||
|
||
write_conf_file() { | ||
# Write a config-file to override '.env'. | ||
cat <<-EOF > conf | ||
GIT_DEPLOY_EMAIL=conf-email | ||
GIT_DEPLOY_APPEND_HASH=conf-file | ||
EOF | ||
} | ||
|
||
@test 'Arg-parsing defaults to in-script values.' { | ||
parse_args | ||
assert that "$append_hash" = "true" | ||
} | ||
|
||
@test ' overrides script defaults with environment variables.' { | ||
set_env_vars | ||
|
||
parse_args | ||
assert that "$append_hash" = "env-var" | ||
} | ||
|
||
@test ' overrides environment variables with .env file.' { | ||
set_env_vars | ||
write_env_file | ||
|
||
parse_args | ||
assert that "$append_hash" = "env-file" | ||
} | ||
|
||
@test ' overrides .env with a file specified on the command-line.' { | ||
set_env_vars | ||
write_env_file | ||
write_conf_file | ||
|
||
parse_args --config-file conf | ||
assert that "$append_hash" = "conf-file" | ||
} | ||
|
||
@test ' overrides everything with a command-line option.' { | ||
set_env_vars | ||
write_env_file | ||
write_conf_file | ||
|
||
parse_args --config-file conf --no-hash | ||
assert that "$append_hash" = "false" | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.