1+ // Managed By : CloudDrove
2+ // Description : This Terratest is used to test the Terraform Elasticache module.
3+ // Copyright @ CloudDrove. All Right Reserved.
4+ package test
5+
6+ import (
7+ "testing"
8+ "strings"
9+ "github.com/stretchr/testify/assert"
10+ "github.com/gruntwork-io/terratest/modules/terraform"
11+ )
12+
13+ func Test (t * testing.T ) {
14+ t .Parallel ()
15+
16+ terraformOptions := & terraform.Options {
17+ // Source path of Terraform directory.
18+ TerraformDir : "../_example" ,
19+ Upgrade : true ,
20+ }
21+
22+ // This will run 'terraform init' and 'terraform application' and will fail the test if any errors occur
23+ terraform .InitAndApply (t , terraformOptions )
24+
25+ // To clean up any resources that have been created, run 'terraform destroy' towards the end of the test
26+ defer terraform .Destroy (t , terraformOptions )
27+
28+ // To get the value of an output variable, run 'terraform output'
29+ Id := strings .Join (terraform .OutputList (t , terraformOptions , "id" )," " )
30+ Tags := terraform .OutputMap (t , terraformOptions , "tags" )
31+
32+ // Verify we're getting back the outputs we expect
33+ assert .Contains (t , Id , "s-" )
34+ assert .Equal (t , "test-redis-cd" , Tags ["Name" ])
35+ }
0 commit comments