Version: v0.0.0-...-314d90f Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2019 License: MIT Imports: 8 Imported by: 0



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.



This section is empty.


This section is empty.


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.


type ResourceAttributeValueMapping

type ResourceAttributeValueMapping map[string]map[string]string

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL