Skip to content

Commit

Permalink
Merge pull request #8 from minamijoyo/fix-unstable-tests
Browse files Browse the repository at this point in the history
Fix unstable tests
  • Loading branch information
minamijoyo authored Nov 16, 2020
2 parents b7d9065 + 85c7028 commit 74350a0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test: deps

.PHONY: testacc
testacc: deps
TEST_ACC=1 go test -count=1 ./...
TEST_ACC=1 go test -count=1 -failfast ./...

.PHONY: check
check: lint vet test build
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ services:
environment:
CGO_ENABLED: 0 # disable cgo for go test
LOCALSTACK_ENDPOINT: "http://localstack:4566"
# Use the same filesystem to avoid a checksum mismatch error
# or a file busy error caused by asynchronous IO.
TF_PLUGIN_CACHE_DIR: "/tmp/plugin-cache"
depends_on:
- localstack

Expand Down
8 changes: 8 additions & 0 deletions tfexec/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ func SetupTestAccWithApply(t *testing.T, source string) TerraformCLI {
t.Fatalf("failed to run terraform apply: %s", err)
}

// destroy resources after each test not to have any state.
t.Cleanup(func() {
err := tf.Destroy(ctx, "", "-input=false", "-no-color", "-auto-approve")
if err != nil {
t.Fatalf("failed to run terraform destroy: %s", err)
}
})

return tf
}

Expand Down
5 changes: 5 additions & 0 deletions tfmigrate/state_import_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ resource "aws_iam_user" "baz" {
if err != nil {
t.Fatalf("failed to run migrator plan: %s", err)
}

err = m.Apply(ctx)
if err != nil {
t.Fatalf("failed to run migrator apply: %s", err)
}
}

0 comments on commit 74350a0

Please sign in to comment.