-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor e2e setup and add additional tests
- Loading branch information
1 parent
4b672ec
commit 5bf502a
Showing
5 changed files
with
82 additions
and
7 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
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,13 @@ | ||
resource "null_resource" "untagged_resource" { | ||
triggers = { | ||
always_run = timestamp() | ||
} | ||
} | ||
|
||
terraform { | ||
required_providers { | ||
null = { | ||
source = "hashicorp/null" | ||
} | ||
} | ||
} |
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,39 @@ | ||
setup() { | ||
# Copy files to a read/write directory. This is necessary because | ||
# Terraform generates a lock file in the working directory. | ||
export ORIGINAL_DIR=$(pwd) | ||
cp -r "$BATS_TEST_DIRNAME/artifacts/." $BATS_TEST_TMPDIR | ||
cd $BATS_TEST_TMPDIR | ||
terraform init > /dev/null | ||
|
||
} | ||
|
||
teardown() { | ||
cd $ORIGINAL_DIR | ||
|
||
# Print additional information when a test fails | ||
echo "$status" | ||
echo "$output" | ||
} | ||
|
||
@test "should return 2 if the plan does not exist" { | ||
# When | ||
run "/code/terraapprove" "." "./test.tfplan.json" | ||
|
||
# Expect | ||
[ "$status" -ge 2 ] | ||
grep "Error while reading plan" <<< "$output" | ||
} | ||
|
||
@test "should return 2 if the code base does not exist" { | ||
#Given | ||
terraform plan -out test.tfplan > /dev/null | ||
terraform show -json test.tfplan > ${BATS_TEST_TMPDIR}/test.tfplan.json | ||
|
||
# When | ||
run "/code/terraapprove" "/tmp/notexist" "./test.tfplan.json" | ||
|
||
# Expect | ||
[ "$status" -ge 2 ] | ||
grep "Error while reading code base" <<< "$output" | ||
} |
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
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