Skip to content

Commit 8b97c43

Browse files
committed
updating hello world test
1 parent 16ca7f9 commit 8b97c43

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ output "additional_grants" {
1717
value = keys(module.additional_grants)
1818
description = "Additional grants"
1919
}
20+
21+
# Add a Hello World output for Terratest
22+
output "hello_world" {
23+
value = local.enabled ? "Hello, Terratest!" : null
24+
description = "A simple Hello World output for Terratest validation."
25+
}

test/hello_world_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/gruntwork-io/terratest/modules/terraform"
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestHelloWorld(t *testing.T) {
11+
t.Parallel()
12+
13+
// Define Terraform options
14+
terraformOptions := &terraform.Options{
15+
TerraformDir: "../", // Path to the Terraform module directory
16+
}
17+
18+
// Clean up resources at the end
19+
defer terraform.Destroy(t, terraformOptions)
20+
21+
// Initialize and apply Terraform
22+
terraform.InitAndApply(t, terraformOptions)
23+
24+
// Retrieve the "hello_world" output
25+
helloWorldOutput := terraform.Output(t, terraformOptions, "hello_world")
26+
27+
// Validate the output
28+
assert.Equal(t, "Hello, Terratest!", helloWorldOutput, "Output does not match expected value")
29+
}

0 commit comments

Comments
 (0)