Skip to content

Commit 68a726c

Browse files
author
Matt Pearson
committed
Add tests for '.env' files.
1 parent cd03b06 commit 68a726c

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/env-file.bats

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bats
2+
3+
source lib/assert.bash
4+
source deploy.sh --source-only
5+
6+
envfile_backup=.env.bats-bak
7+
8+
setup() {
9+
export GIT_DEPLOY_USERNAME=env-username
10+
export GIT_DEPLOY_EMAIL=env-email
11+
export GIT_DEPLOY_DIR=env-dir
12+
export GIT_DEPLOY_BRANCH=env-branch
13+
export GIT_DEPLOY_REPO=env-repo
14+
export GIT_DEPLOY_APPEND_HASH=env-hash
15+
16+
if [ -e .env ]; then
17+
mv .env $envfile_backup
18+
fi
19+
20+
cat <<-EOF > .env
21+
GIT_DEPLOY_USERNAME=dotenv-username
22+
GIT_DEPLOY_EMAIL=dotenv-email
23+
GIT_DEPLOY_DIR=dotenv-dir
24+
GIT_DEPLOY_BRANCH=dotenv-branch
25+
GIT_DEPLOY_REPO=dotenv-repo
26+
GIT_DEPLOY_APPEND_HASH=dotenv-hash
27+
EOF
28+
}
29+
30+
teardown() {
31+
rm .env
32+
if [ -e "$envfile_backup" ]; then
33+
mv $envfile_backup .env
34+
fi
35+
}
36+
37+
@test 'dotenv variable: DEFAULT_USERNAME' {
38+
assert that `parse_args && echo $default_username` = "dotenv-username"
39+
}
40+
@test 'dotenv variable: DEFAULT_EMAIL' {
41+
assert that `parse_args && echo $default_email` = "dotenv-email"
42+
}
43+
@test 'dotenv variable: GIT_DEPLOY_DIR' {
44+
assert that `parse_args && echo $deploy_directory` = "dotenv-dir"
45+
}
46+
@test 'dotenv variable: GIT_DEPLOY_BRANCH' {
47+
assert that `parse_args && echo $deploy_branch` = "dotenv-branch"
48+
}
49+
@test 'dotenv variable: GIT_DEPLOY_REPO' {
50+
assert that `parse_args && echo $repo` = "dotenv-repo"
51+
}
52+
@test 'dotenv variable: GIT_DEPLOY_APPEND_HASH' {
53+
assert that `parse_args && echo $append_hash` = "dotenv-hash"
54+
}
55+

0 commit comments

Comments
 (0)