helpers

package
v0.69.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Package helpers provides helper functions for tests.

Index

Constants

View Source
const (
	TerraformFolder = ".terraform"

	TerraformState = "terraform.tfstate"

	TerraformRemoteStateS3Region = "us-west-2"

	TerraformStateBackup = "terraform.tfstate.backup"
	TerragruntCache      = ".terragrunt-cache"

	TerraformBinary = "terraform"
	TofuBinary      = "tofu"

	TerragruntDebugFile = "terragrunt-debug.tfvars.json"

	// Repeated right now, but it might not be later.
	TestFixtureOutDir = "fixtures/out-dir"
)

Variables

View Source
var RootFolder = "/"

Functions

func CleanupTerraformFolder added in v0.68.13

func CleanupTerraformFolder(t *testing.T, templatesPath string)

func CleanupTerragruntFolder added in v0.68.13

func CleanupTerragruntFolder(t *testing.T, templatesPath string)

func CopyAndFillMapPlaceholders added in v0.68.13

func CopyAndFillMapPlaceholders(t *testing.T, srcPath string, destPath string, placeholders map[string]string)

func CopyEnvironment added in v0.68.13

func CopyEnvironment(t *testing.T, environmentPath string, includeInCopy ...string) string

func CopyTerragruntConfigAndFillPlaceholders added in v0.68.13

func CopyTerragruntConfigAndFillPlaceholders(t *testing.T, configSrcPath string, configDestPath string, s3BucketName string, lockTableName string, region string)

func CreateEmptyStateFile added in v0.68.13

func CreateEmptyStateFile(t *testing.T, testPath string)

func CreateTmpTerragruntConfig added in v0.68.13

func CreateTmpTerragruntConfig(t *testing.T, templatesPath string, s3BucketName string, lockTableName string, configFileName string) string

func CreateTmpTerragruntConfigContent added in v0.68.13

func CreateTmpTerragruntConfigContent(t *testing.T, contents string, configFileName string) string

func CreateTmpTerragruntConfigWithParentAndChild added in v0.68.13

func CreateTmpTerragruntConfigWithParentAndChild(t *testing.T, parentPath string, childRelPath string, s3BucketName string, parentConfigFileName string, childConfigFileName string) string

func DeleteS3Bucket added in v0.68.13

func DeleteS3Bucket(t *testing.T, awsRegion string, bucketName string, opts ...options.TerragruntOptionsFunc)

DeleteS3Bucket deletes the specified S3 bucket to clean up after a test, and fails the test if there was an error.

func DeleteS3BucketE added in v0.68.13

func DeleteS3BucketE(t *testing.T, awsRegion string, bucketName string, opts ...options.TerragruntOptionsFunc) error

DeleteS3BucketE deletes the specified S3 bucket potentially with error to clean up after a test.

func ExpectedWrongCommandErr added in v0.68.13

func ExpectedWrongCommandErr(command string) error

ExpectedWrongCommandErr - return expected error message for wrong command

func FileIsInFolder added in v0.68.13

func FileIsInFolder(t *testing.T, name string, path string) bool

func FindFilesWithExtension added in v0.68.13

func FindFilesWithExtension(dir string, ext string) ([]string, error)

func GetPathRelativeTo added in v0.68.13

func GetPathRelativeTo(t *testing.T, path string, basePath string) string

func GetPathsRelativeTo added in v0.68.13

func GetPathsRelativeTo(t *testing.T, basePath string, paths []string) []string

func IsTerraform added in v0.68.13

func IsTerraform() bool

func LogBufferContentsLineByLine added in v0.68.13

func LogBufferContentsLineByLine(t *testing.T, out bytes.Buffer, label string)

func RemoveFile added in v0.68.13

func RemoveFile(t *testing.T, path string)

func RemoveFolder added in v0.68.13

func RemoveFolder(t *testing.T, path string)

func RunNetworkMirrorServer added in v0.68.13

func RunNetworkMirrorServer(t *testing.T, ctx context.Context, urlPrefix, providerDir, token string) *url.URL

func RunTerragrunt added in v0.68.13

func RunTerragrunt(t *testing.T, command string)

func RunTerragruntCommand added in v0.68.13

func RunTerragruntCommand(t *testing.T, command string, writer io.Writer, errwriter io.Writer) error

func RunTerragruntCommandWithContext added in v0.69.1

func RunTerragruntCommandWithContext(t *testing.T, ctx context.Context, command string, writer io.Writer, errwriter io.Writer) error

func RunTerragruntCommandWithOutput added in v0.68.13

func RunTerragruntCommandWithOutput(t *testing.T, command string) (string, string, error)

func RunTerragruntCommandWithOutputWithContext added in v0.69.1

func RunTerragruntCommandWithOutputWithContext(t *testing.T, ctx context.Context, command string) (string, string, error)

func RunTerragruntRedirectOutput added in v0.68.13

func RunTerragruntRedirectOutput(t *testing.T, command string, writer io.Writer, errwriter io.Writer)

func RunTerragruntValidateInputs added in v0.68.13

func RunTerragruntValidateInputs(t *testing.T, moduleDir string, extraArgs []string, isSuccessTest bool)

func RunTerragruntVersionCommand added in v0.68.13

func RunTerragruntVersionCommand(t *testing.T, ver string, command string, writer io.Writer, errwriter io.Writer) error

func RunValidateAllWithIncludeAndGetIncludedModules added in v0.68.13

func RunValidateAllWithIncludeAndGetIncludedModules(t *testing.T, rootModulePath string, includeModulePaths []string, strictInclude bool) []string

func TestRunAllPlan added in v0.68.13

func TestRunAllPlan(t *testing.T, args string) (string, string, string, error)

func UniqueID added in v0.68.13

func UniqueID() string

UniqueID returns a unique (ish) id we can attach to resources and tfstate files so they don't conflict with each other Uses base 62 to generate a 6 character string that's unlikely to collide with the handful of tests we run in parallel. Based on code here: http://stackoverflow.com/a/9543797/483528

func ValidateOutput added in v0.68.13

func ValidateOutput(t *testing.T, outputs map[string]TerraformOutput, key string, value interface{})

func WrappedBinary added in v0.68.13

func WrappedBinary() string

WrappedBinary - return which binary will be wrapped by Terragrunt, useful in CICD to run same tests against tofu and terraform

Types

type FakeProvider added in v0.68.13

type FakeProvider struct {
	RegistryName string
	Namespace    string
	Name         string
	Version      string
	PlatformOS   string
	PlatformArch string
}

func (*FakeProvider) CreateMirror added in v0.68.13

func (provider *FakeProvider) CreateMirror(t *testing.T, rootDir string)

type TerraformOutput added in v0.68.13

type TerraformOutput struct {
	Sensitive bool        `json:"Sensitive"`
	Type      interface{} `json:"Type"`
	Value     interface{} `json:"Value"`
}

Jump to

Keyboard shortcuts

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