mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-10 12:51:14 +00:00
38 lines
864 B
Go
38 lines
864 B
Go
package test
|
|
|
|
import (
|
|
"crypto/tls"
|
|
"fmt"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/gruntwork-io/terratest/modules/http-helper"
|
|
"github.com/gruntwork-io/terratest/modules/terraform"
|
|
)
|
|
|
|
func TestTerraformHelloWorldExample(t *testing.T) {
|
|
// retryable errors in terraform testing.
|
|
terraformOptions := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
|
|
TerraformDir: "../../examples/hello-world",
|
|
})
|
|
|
|
defer terraform.Destroy(t, terraformOptions)
|
|
|
|
terraform.InitAndApply(t, terraformOptions)
|
|
|
|
instanceURL := terraform.Output(t, terraformOptions, "url")
|
|
tlsConfig := tls.Config{}
|
|
maxRetries := 30
|
|
timeBetweenRetries := 5 * time.Second
|
|
|
|
http_helper.HttpGetWithRetryWithCustomValidation(
|
|
t, instanceURL, &tlsConfig, maxRetries, timeBetweenRetries, validate,
|
|
)
|
|
|
|
}
|
|
|
|
func validate(status int, body string) bool {
|
|
fmt.Println(body)
|
|
return status == 200
|
|
}
|