Skip to content

Commit d84e3a8

Browse files
authored
Fix broken & disabled tests (#105)
1 parent f79a217 commit d84e3a8

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

examples/vpc-endpoints/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ module "vpc_endpoints" {
6464

6565
module "subnets" {
6666
source = "cloudposse/dynamic-subnets/aws"
67-
version = "0.39.8"
67+
version = "0.40.1"
6868

6969
availability_zones = var.availability_zones
7070
vpc_id = module.vpc.vpc_id

test/src/examples_complete_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,36 @@ func TestExamplesComplete(t *testing.T) {
6060
expectedPublicSubnetCidrs := []string{"172.16.96.0/19", "172.16.128.0/19"}
6161
assert.Equal(t, expectedPublicSubnetCidrs, publicSubnetCidrs)
6262
}
63+
64+
func TestExamplesCompleteDisabled(t *testing.T) {
65+
t.Parallel()
66+
randID := strings.ToLower(random.UniqueId())
67+
attributes := []string{randID}
68+
69+
rootFolder := "../../"
70+
terraformFolderRelativeToRoot := "examples/complete"
71+
varFiles := []string{"fixtures.us-east-2.tfvars"}
72+
73+
tempTestFolder := test_structure.CopyTerraformFolderToTemp(t, rootFolder, terraformFolderRelativeToRoot)
74+
75+
terraformOptions := &terraform.Options{
76+
// The path to where our Terraform code is located
77+
TerraformDir: tempTestFolder,
78+
Upgrade: true,
79+
// Variables to pass to our Terraform code using -var-file options
80+
VarFiles: varFiles,
81+
Vars: map[string]interface{}{
82+
"attributes": attributes,
83+
"enabled": "false",
84+
},
85+
}
86+
87+
// At the end of the test, run `terraform destroy` to clean up any resources that were created
88+
defer cleanup(t, terraformOptions, tempTestFolder)
89+
90+
// This will run `terraform init` and `terraform apply` and fail the test if there are any errors
91+
results := terraform.InitAndApply(t, terraformOptions)
92+
93+
// Should complete successfully without creating or changing any resources
94+
assert.Contains(t, results, "Resources: 0 added, 0 changed, 0 destroyed.")
95+
}

test/src/examples_vpc_endpoints_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ type VpcEndpoint struct {
3333
}
3434

3535
// Test the Terraform module in examples/vpc_endpoints using Terratest.
36-
func disabledTestExamplesVPCEndpoints(t *testing.T) {
36+
func TestExamplesVPCEndpoints(t *testing.T) {
3737
// Be careful with t.Parallel() unless you are using test_structure.CopyTerraformFolderToTemp
3838
// or else you risk parallel executions clobbering each other's state or
3939
// not really running in parallel due to state locks. We can do it here
4040
// because each test is in its own directory.
4141
t.Parallel()
42+
4243
randID := strings.ToLower(random.UniqueId())
4344
attributes := []string{randID}
4445

0 commit comments

Comments
 (0)