func validateTerraformOutputKeyValues(t *testing.T, fixture *IntegrationTestFixture, output TerraformOutput) {
	for expectedKey, expectedValue := range fixture.ExpectedTfOutput {
		actualValue, isFound := output[expectedKey]
		if !isFound {
			fixture.GoTest.Fatalf("Output unexpectedly did not contain key %s", expectedKey)
		}
		expectedAsJSON := jsonOrFail(fixture, expectedValue)
		actualAsJSON := jsonOrFail(fixture, actualValue)
		if expectedAsJSON != actualAsJSON {
			t.Fatalf(
				"Output value for '%s' was expected to be '%s' but was '%s'",
				expectedKey,
				expectedAsJSON,
				actualAsJSON,
			)
		}
	}
}
Validates that any outputs that the user supplies match the actual terraform outputs.
Note: the comparison is done by converting the expected and actual values into JSON and
doing a string comparison. This solves a number of complexities, such as:
- Handles comparison of generic data types automatically
- Handles differences in key ordering for maps
- Handles all handling of generics, which is tricky in Go
package integration
import (
	"encoding/json"
	"fmt"
	"testing"
	"github.com/gruntwork-io/terratest/modules/terraform"
)
type TerraformOutput map[string]interface{}
type TerraformOutputValidation func(goTest *testing.T, output TerraformOutput)
type IntegrationTestFixture struct {
	GoTest                *testing.T                   
	TfOptions             *terraform.Options           
	SkipInit              bool                         
	ExpectedTfOutputCount int                          
	ExpectedTfOutput      TerraformOutput              
	TfOutputAssertions    []TerraformOutputValidation  
}
func RunIntegrationTests(fixture *IntegrationTestFixture) {
	if !fixture.SkipInit {
		terraform.Init(fixture.GoTest, fixture.TfOptions)
	}
	output := terraform.OutputAll(fixture.GoTest, fixture.TfOptions)
	validateTerraformOutput(fixture, TerraformOutput(output))
}
func validateTerraformOutput(fixture *IntegrationTestFixture, output TerraformOutput) {
	fixture.GoTest.Run("Terraform Output Count", func(t *testing.T) {
		validateTerraformOutputCount(t, fixture, output)
	})
	fixture.GoTest.Run("Terraform Output Key Values", func(t *testing.T) {
		validateTerraformOutputKeyValues(t, fixture, output)
	})
	for i, outputAssertion := range fixture.TfOutputAssertions {
		fixture.GoTest.Run(fmt.Sprintf("Custom Validation Function (%d)", i), func(t *testing.T) {
			outputAssertion(t, output)
		})
	}
}
func validateTerraformOutputCount(t *testing.T, fixture *IntegrationTestFixture, output TerraformOutput) {
	if len(output) != fixture.ExpectedTfOutputCount {
		t.Fatalf(
			"Output unexpectedly had %d entries instead of %d",
			len(output),
			fixture.ExpectedTfOutputCount,
		)
	}
}