Skip to content

Commit 1e2041f

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

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/env-file.bats

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
15+
if [ -e .env ]; then
16+
mv .env $envfile_backup
17+
fi
18+
19+
cat <<-EOF > .env
20+
GIT_DEPLOY_USERNAME=dotenv-username
21+
GIT_DEPLOY_EMAIL=dotenv-email
22+
GIT_DEPLOY_DIR=dotenv-dir
23+
GIT_DEPLOY_BRANCH=dotenv-branch
24+
GIT_DEPLOY_REPO=dotenv-repo
25+
EOF
26+
}
27+
28+
teardown() {
29+
rm .env
30+
if [ -e "$envfile_backup" ]; then
31+
mv $envfile_backup .env
32+
fi
33+
}
34+
35+
@test 'dotenv variable: DEFAULT_USERNAME' {
36+
assert that `parse_args && echo $default_username` = "dotenv-username"
37+
}
38+
@test 'dotenv variable: DEFAULT_EMAIL' {
39+
assert that `parse_args && echo $default_email` = "dotenv-email"
40+
}
41+
@test 'dotenv variable: GIT_DEPLOY_DIR' {
42+
assert that `parse_args && echo $deploy_directory` = "dotenv-dir"
43+
}
44+
@test 'dotenv variable: GIT_DEPLOY_BRANCH' {
45+
assert that `parse_args && echo $deploy_branch` = "dotenv-branch"
46+
}
47+
@test 'dotenv variable: GIT_DEPLOY_REPO' {
48+
assert that `parse_args && echo $repo` = "dotenv-repo"
49+
}
50+

0 commit comments

Comments
 (0)