Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YakDriver/e49945e52e80c89e7670de7da350a31e to your computer and use it in GitHub Desktop.
Save YakDriver/e49945e52e80c89e7670de7da350a31e to your computer and use it in GitHub Desktop.
Running acceptance tests for Terraform Providers in go
# Hashicorp documentation is a bit out of date so it took a minute to figure this out...
# 1. Install go
https://golang.org/dl/
# 2. Make a go workspace
$ mkdir ~/go # or wherever you want
$ export GOPATH=~/go # could add to .bash_profile
$ export PATH=$GOPATH:$PATH
# 3. Clone/build terraform
$ cd $GOPATH
$ mkdir -p src/github.com/hashicorp
$ cd src/github.com/hashicorp/
$ git clone https://github.com/hashicorp/terraform.git
$ cd terraform/
$ make
# 4. Fork/code
fork the main repository for your provider (e.g., https://github.com/terraform-providers/terraform-provider-aws.git)
make your changes, add your acceptance test
# 5. Clone YOUR terraform-providers (separate git)
$ mkdir -p $GOPATH/src/github.com/terraform-providers
$ cd $GOPATH/src/github.com/terraform-providers
$ git clone https://github.com/<YOUR-REPO>/terraform-provider-aws.git
# 6. Run acceptance test
$ make testacc TEST=github.com/terraform-providers/terraform-provider-aws/aws TESTARGS='-run=TestAccAWSSpotInstanceRequest_withoutSpotPrice'
# 7. Successful output looks like...
==> Checking that code complies with gofmt requirements...
go generate ./...
2018/03/06 18:36:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test github.com/terraform-providers/terraform-provider-aws/aws -v -run=TestAccAWSSpotInstanceRequest_withoutSpotPrice -timeout 120m
=== RUN TestAccAWSSpotInstanceRequest_withoutSpotPrice
--- PASS: TestAccAWSSpotInstanceRequest_withoutSpotPrice (85.06s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 85.111s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment