testskeleton

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrors

func AssertErrors(t *testing.T, err error, assertList []AssertExpression)

Function is comparing every provided error in expressions lists and checks value using expression defined in the list

func AssertOutputs

func AssertOutputs(t *testing.T, terraformOptions *terraform.Options, assertList []AssertExpression)

Function is comparing every provided output in expressions lists and checks value using expression defined in the list

func DeployInfraCheckOutputs

func DeployInfraCheckOutputs(t *testing.T, terraformOptions *terraform.Options, assertList []AssertExpression) *terraform.Options

Function is responsible for deployment of the infrastructure, verify assert expressions and destroy infrastructure

func DeployInfraCheckOutputsVerifyChanges

func DeployInfraCheckOutputsVerifyChanges(t *testing.T, terraformOptions *terraform.Options, assertList []AssertExpression) *terraform.Options

Function is responsible for deployment of the infrastructure, verify assert expressions, verify if there are no changes in plan after deployment and destroy infrastructure

func DeployInfraCheckOutputsVerifyChangesDeployChanges

func DeployInfraCheckOutputsVerifyChangesDeployChanges(t *testing.T, terraformOptions *terraform.Options,
	assertList []AssertExpression, additionalChangesAfterDeployment []AdditionalChangesAfterDeployment) *terraform.Options

Function is responsible for deployment of the infrastructure, verify assert expressions, verify if there are no changes in plan after deployment and destroy infrastructure

func DeployInfraNoCheckOutputsNoDestroy

func DeployInfraNoCheckOutputsNoDestroy(t *testing.T, terraformOptions *terraform.Options) *terraform.Options

Function is responsible only for deployment of the infrastructure, no verification of assert expressions and no destroyment of the infrastructure

func GenericDeployInfraAndVerifyAssertChanges

func GenericDeployInfraAndVerifyAssertChanges(t *testing.T,
	terraformOptions *terraform.Options,
	assertList []AssertExpression,
	checkNoChanges bool,
	additionalChangesAfterDeployment []AdditionalChangesAfterDeployment,
	destroyInfraAtEnd bool) *terraform.Options

Generic deployment function used in wrapper functions above

  • terraformOptions - Terraform options required to execute tests in Terratest
  • assertList - list of assert expression
  • checkNoChanges - if true, after deployment check if there are no changes planed
  • additionalChangesAfterDeployment - if not empty, then it contains list of additional variables values and resources in external file to plan and deploy in order to verify if all expected changes are being provisioned, nothing more or less
  • destroyInfraAtEnd - if true, destroy infrastructure at the end of test

func PlanInfraCheckErrors

func PlanInfraCheckErrors(t *testing.T, terraformOptions *terraform.Options,
	assertList []AssertExpression, noErrorsMessage string) *terraform.Options

Functions is response for planning deployment, verify errors expressions (no changes are deployed)

func ValidateCode

func ValidateCode(t *testing.T, terraformOptions *terraform.Options) *terraform.Options

Function running only only code validation.

Types

type AdditionalChangesAfterDeployment

type AdditionalChangesAfterDeployment struct {
	AdditionalVarsValues map[string]interface{}
	UseVarFiles          []string
	FileNameWithTfCode   string
	ChangedResources     []ChangedResource
}

type AssertExpression

type AssertExpression struct {
	OutputName    string
	Operation     AssertOperation
	ExpectedValue interface{}
	Message       string
	Check         CheckFunction
	TestedValue   string
}

Structure used to assert each output value by comparing it to expected value using defined operation.

type AssertOperation

type AssertOperation int64

Enum for operations in assert expressions

const (
	NotEmpty AssertOperation = iota
	Empty
	Equal
	NotFound
	ListLengthEqual
	StartsWith
	CheckFunctionWithOutput
	CheckFunctionWithValue
	EqualToValue
	ErrorContains
)

type ChangedResource

type ChangedResource struct {
	Name   string
	Action tfjson.Action
}

Structure used to verify if there are changes in resources after adding additional Terraform code or after changing values of some variables

type CheckFunction

type CheckFunction func(t *testing.T, outputValue string) bool

Sometimes there is a need to execute custom function to check something, so then in assert expression we need to provide function, which results is compared to true

type TerraformVarsInfo

type TerraformVarsInfo struct {
	NamePrefix              string
	AzureResourceGroupName  string
	AzureStorageAccountName string
	GoogleProjectId         string
}

Structure used for terraform tfvars input information, not all options are used in all public cloud environments

func GenerateTerraformVarsInfo

func GenerateTerraformVarsInfo(cloud string) (TerraformVarsInfo, error)

Function that generates and returns information used by Terraform TFVARS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL