Documentation ¶
Index ¶
- Constants
- func CleanupTestData(t *testing.T, path string)
- func CopyTerraformFolderToTemp(t *testing.T, rootFolder string, examplesFolder string, testName string) string
- func FormatTestDataPath(testFolder string, filename string) string
- func IsTestDataPresent(t *testing.T, path string) bool
- func LoadAmiId(t *testing.T, testFolder string) string
- func LoadEc2KeyPair(t *testing.T, testFolder string) *aws.Ec2Keypair
- func LoadInt(t *testing.T, testFolder string, name string) int
- func LoadPackerOptions(t *testing.T, testFolder string) *packer.Options
- func LoadString(t *testing.T, testFolder string, name string) string
- func LoadTerraformOptions(t *testing.T, testFolder string) *terraform.Options
- func LoadTestData(t *testing.T, path string, value interface{})
- func RunTestStage(t *testing.T, stageName string, stage func())
- func SaveAmiId(t *testing.T, testFolder string, amiId string)
- func SaveEc2KeyPair(t *testing.T, testFolder string, keyPair *aws.Ec2Keypair)
- func SaveInt(t *testing.T, testFolder string, name string, val int)
- func SavePackerOptions(t *testing.T, testFolder string, packerOptions *packer.Options)
- func SaveString(t *testing.T, testFolder string, name string, val string)
- func SaveTerraformOptions(t *testing.T, testFolder string, terraformOptions *terraform.Options)
- func SaveTestData(t *testing.T, path string, value interface{})
- func SkipStageEnvVarSet() bool
Constants ¶
const SKIP_STAGE_ENV_VAR_PREFIX = "SKIP_"
Variables ¶
This section is empty.
Functions ¶
func CleanupTestData ¶
Clean up the test data at the given path
func CopyTerraformFolderToTemp ¶
func CopyTerraformFolderToTemp(t *testing.T, rootFolder string, examplesFolder string, testName string) string
Copy the given root folder to a randomly-named temp folder and return the path to the given examples folder within the new temp root folder. This is useful when running multiple tests in parallel against the same set of Terraform files to ensure the tests don't overwrite each other's .terraform working directory and terraform.tfstate files. To ensure relative paths work, we copy over the entire root folder to a temp folder, and then return the path within that temp folder to the given example dir, which is where the actual test will be running.
Note that if any of the SKIP_<stage> environment variables is set, we assume this is a test in the local dev where there are no other concurrent tests running and we want to be able to cache test data between test stages, so in that case, we do NOT copy anything to a temp folder, an dreturn the path to the original examples folder instead.
func FormatTestDataPath ¶
Format a path to save test data
func IsTestDataPresent ¶
Return true if a file exists at $path and the test data there is non-empty.
func LoadAmiId ¶
Load and unserialize an AMI ID from the given folder. This allows you to reuse an AMI that was created during an earlier setup step in later validation and teardown steps.
func LoadEc2KeyPair ¶
func LoadEc2KeyPair(t *testing.T, testFolder string) *aws.Ec2Keypair
Load and unserialize an Ec2KeyPair from the given folder. This allows you to reuse an Ec2KeyPair that was created during an earlier setup step in later validation and teardown steps.
func LoadInt ¶
Load a uniquely named int value from the given folder. This allows you to reuse one or more int values that were created during an earlier setup step in later steps.
func LoadPackerOptions ¶
Load and unserialize PackerOptions from the given folder. This allows you to reuse a PackerOptions that was created during an earlier setup step in later validation and teardown steps.
func LoadString ¶
Load and unserialize a uniquely named string value from the given folder. This allows you to reuse one or more string values that were created during an earlier setup step in later steps.
func LoadTerraformOptions ¶
Load and unserialize TerraformOptions from the given folder. This allows you to reuse a TerraformOptions that was created during an earlier setup step in later validation and teardown steps.
func LoadTestData ¶
Load and unserialize a value stored at the given path. The value should be a pointer to a struct into which the value will be deserialized. This allows you to reuse some sort of test data (e.g., TerraformOptions) from earlier setup steps in later validation and teardown steps.
func RunTestStage ¶
Execute the given test stage (e.g., setup, teardown, validation) if an environment variable of the name `SKIP_<stageName>` (e.g., SKIP_teardown) is not set.
func SaveAmiId ¶
Serialize and save an AMI ID into the given folder. This allows you to build an AMI during setup and to reuse that AMI later during validation and teardown.
func SaveEc2KeyPair ¶
func SaveEc2KeyPair(t *testing.T, testFolder string, keyPair *aws.Ec2Keypair)
Serialize and save an Ec2KeyPair into the given folder. This allows you to create an Ec2KeyPair during setup and to reuse that Ec2KeyPair later during validation and teardown.
func SaveInt ¶
Save a uniquely named int value into the given folder. This allows you to create one or more int values during one stage -- each with a unique name -- and to reuse those values during later stages.
func SavePackerOptions ¶
Serialize and save PackerOptions into the given folder. This allows you to create PackerOptions during setup and to reuse that PackerOptions later during validation and teardown.
func SaveString ¶
Serialize and save a uniquely named string value into the given folder. This allows you to create one or more string values during one stage -- each with a unique name -- and to reuse those values during later stages.
func SaveTerraformOptions ¶
Serialize and save TerraformOptions into the given folder. This allows you to create TerraformOptions during setup and to reuse that TerraformOptions later during validation and teardown.
func SaveTestData ¶
Serialize and save a value used at test time to the given path. This allows you to create some sort of test data (e.g., TerraformOptions) during setup and to reuse this data later during validation and teardown.
func SkipStageEnvVarSet ¶
func SkipStageEnvVarSet() bool
Returns true if an environment variable is set instructing Terratest to skip a test stage. This can be an easy way to tell if the tests are running in a local dev environment vs a CI server.
Types ¶
This section is empty.