Documentation ¶
Overview ¶
Package `infratests` is intended to act as a testing harness that makes testing Terraform templates easy and efficient. The goal of this package is to minimize the boiler plate code required to effectively test terraform implementations.
The current implementation is focused only on unit tests but it will be expanded to harness integration tests as well.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunUnitTests ¶
func RunUnitTests(fixture *UnitTestFixture)
Executes terraform lifecycle events and verifies the correctness of the resulting terraform. The following actions are coordinated:
- Run `terraform init`
- Create new terraform workspace. This helps prevent accidentally deleting resources
- Run `terraform plan`
- Validate terraform plan file.
Types ¶
type TerraformPlanValidation ¶
type TerraformPlanValidation func(goTest *testing.T, plan *terraformCore.Plan)
type UnitTestFixture ¶
type UnitTestFixture struct { GoTest *testing.T // Go test harness TfOptions *terraform.Options // Terraform options ExpectedResourceCount int // Expected # of resources that Terraform should create // map of maps specifying resource <--> attribute <--> attribute value mappings ExpectedResourceAttributeValues ResourceAttributeValueMapping PlanAssertions []TerraformPlanValidation // user-defined plan assertions }
Holds metadata required to execute a unit test against a test against a terraform template
Click to show internal directories.
Click to hide internal directories.