allow skipping test runs @mcalhoun (#40)
what
- allow skipping test runs with the
-skip-tests
flag
why
- to give the developer more flexibility when iterating locally
allow multiple test suites @mcalhoun (#39)
what
- Allow multiple test suites
why
- To allow users to run multiple test suites at the same time
rename randomseed to randomidentifier @mcalhoun (#35)
what
- Rename
RandomSeed
toRandomIdentifier
in theTestSuite
struct
why
- As @Nuru pointed out, the
seed
term makes it confusion and indicates some kind of encryption is taking place, when it's literally just a random ID to prevent resource collision.
implement aws-component-helper @mcalhoun (#30)
what
- Add a new
aws-component-helper
package to allow consumers to easily test Cloud Posse flavored AWS components (root modules) with atmos.
why
- To allow components to be tested using
atmos
stacks, which is generally how they are deployed, especially when deployed within the Cloud Posse Reference Architecture.
how
The new package is meant to be used within go
tests and allows a fairly simple way to test a component:
package test
import (
"fmt"
"testing"
"github.com/cloudposse/test-helpers/pkg/atmos"
helper "github.com/cloudposse/test-helpers/pkg/atmos/aws-component-helper"
"github.com/stretchr/testify/require"
)
var suite *helper.TestSuite
// TestMain is the entry point for the test suite. It initializes the test
// suite and runs the tests.
func TestMain(m *testing.M) {
var err error
// Configure the test suite
suite, err = helper.NewTestSuite("us-east-2", "bastion", "test")
if err != nil {
panic(err)
}
// Add dependencies for the component under test in the same stack. If you
// want to add dependencies in different stacks, use AddCrossStackDependencies.
//
// Dependencies are deployed in serial in the order they are added.
suite.AddDependencies([]string{"vpc"})
// Create a new testing object since TestMain doesn't have one and we need
// one to call the Setup and Teardown functions
t := &testing.T{}
defer suite.TearDown(t)
suite.Setup(t)
m.Run()
}
func TestBastion(t *testing.T) {
additionalVars := map[string]interface{}{}
defer suite.DestroyComponentUnderTest(t, additionalVars)
_, err := suite.DeployComponentUnderTest(t, additionalVars)
require.NoError(t, err)
instanceProfile := atmos.Output(t, suite.AtmosOptions, "iam_instance_profile")
require.Equal(t, instanceProfile, fmt.Sprintf("eg-cptest-ue2-test-bastion-%s", suite.RandomSeed))
}
references
- Cloud Posse's components are located in the https://github.com/cloudposse-terraform-components GitHub Org. Any AWS component that follows the same convention can be tested using this package.