Skip to content

Commit 5bdb662

Browse files
committed
Fix TestHelloWorldAppExample
The test should be checking that the HTTP response *contains* the text "Hello, World" rather than checking for exact equality. It turns out the book itself had the right code in it, but when copying the test code to this repo, I somehow got an old versison of this one test.
1 parent ddb2965 commit 5bdb662

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

code/terraform/07-testing-terraform-code/test/hello_world_app_example_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package test
33
import (
44
"fmt"
55
"github.com/gruntwork-io/terratest/modules/random"
6+
"strings"
67

78
"github.com/gruntwork-io/terratest/modules/http-helper"
89

@@ -36,19 +37,18 @@ func TestHelloWorldAppExample(t *testing.T) {
3637
albDnsName := terraform.OutputRequired(t, opts, "alb_dns_name")
3738
url := fmt.Sprintf("http://%s", albDnsName)
3839

39-
expectedStatus := 200
40-
expectedBody := "Hello, World"
41-
4240
maxRetries := 10
4341
timeBetweenRetries := 10 * time.Second
4442

45-
http_helper.HttpGetWithRetry(
43+
http_helper.HttpGetWithRetryWithCustomValidation(
4644
t,
4745
url,
48-
expectedStatus,
49-
expectedBody,
5046
maxRetries,
5147
timeBetweenRetries,
48+
func(status int, body string) bool {
49+
return status == 200 &&
50+
strings.Contains(body, "Hello, World")
51+
},
5252
)
5353

5454
}

0 commit comments

Comments
 (0)