Created
October 18, 2019 15:26
-
-
Save webdevwilson/3166d921b37454446af3c58b0c506b3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func TestWebServer(t *testing.T) { | |
terraformOptions := &terraform.Options { | |
// The path to where your Terraform code is located | |
TerraformDir: "../web-server", | |
} | |
// At the end of the test, run `terraform destroy` | |
defer terraform.Destroy(t, terraformOptions) | |
// Run `terraform init` and `terraform apply` | |
terraform.InitAndApply(t, terraformOptions) | |
// Run `terraform output` to get the value of an output variable | |
url := terraform.Output(t, terraformOptions, "url") | |
// Verify that we get back a 200 OK with the expected text. It | |
// takes ~1 min for the Instance to boot, so retry a few times. | |
status := 200 | |
text := "Hello, World" | |
retries := 15 | |
sleep := 5 * time.Second | |
http_helper.HttpGetWithRetry(t, url, status, text, retries, sleep) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment