Documentation ¶
Overview ¶
Package testutils gathers reusable pieces useful for testing
Index ¶
- func LoadFixtureBytes(t *testing.T, path string) []byte
- func LoadFixtureString(t *testing.T, format string, args ...interface{}) string
- func MuteLogging(t *testing.T)
- func NewProtoV6ProviderFactory(subproviders ...subprovider.Subprovider) map[string]func() (tfprotov6.ProviderServer, error)
- func TFTestSetup() error
- func TFTestTeardown() error
- func TODO(t *testing.T, message string)
- func TestRunner(m *testing.M)
- type FieldsKnownAtPlan
- type MockCalls
- type TattleT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFixtureBytes ¶
LoadFixtureBytes returns the entire contents of the given file as a byte slice
func LoadFixtureString ¶
LoadFixtureString returns the entire contents of the given file as a string
func MuteLogging ¶
MuteLogging globally prevents logging output unless TEST_LOGGING env var is not empty
func NewProtoV6ProviderFactory ¶
func NewProtoV6ProviderFactory(subproviders ...subprovider.Subprovider) map[string]func() (tfprotov6.ProviderServer, error)
NewProtoV6ProviderFactory uses provided subprovider to create provider factory for test purposes
func TFTestSetup ¶
func TFTestSetup() error
TFTestSetup contains common setup for tests in all subproviders
func TFTestTeardown ¶
func TFTestTeardown() error
TFTestTeardown contains common teardown for tests in all subproviders
func TODO ¶
TODO marks a test as being in a "pending" state and logs a message telling the user why. Such tests are expected to fail for the time being and may exist for the sake of unfinished/future features or to document known failure cases that won't be fixed right away. The failure of a pending test is not considered an error and the test will therefore be skipped unless the TEST_TODO environment variable is set to a non-empty value.
func TestRunner ¶
TestRunner executes common test setup and teardown in all subproviders
Types ¶
type FieldsKnownAtPlan ¶ added in v6.3.0
FieldsKnownAtPlan provides a way to verify if provided list of fields is known at plan level
func (FieldsKnownAtPlan) CheckPlan ¶ added in v6.3.0
func (p FieldsKnownAtPlan) CheckPlan(_ context.Context, request plancheck.CheckPlanRequest, response *plancheck.CheckPlanResponse)
CheckPlan checks a plan file and then returns an error if the plan file does not match what is expected
type MockCalls ¶
MockCalls is a wrapper around []*mock.Call
type TattleT ¶
TattleT wraps a *testing.T to intercept a Testify mock's call of t.FailNow(). When testing.t.FailNow() is called from any goroutine other than the one on which a test was created, it causes the test to hang. Testify's mocks fail to inform the user which test failed. Use this struct to wrap a *testing.TattleT when you call `mock.Test(TattleT{t})` and the mock's failure message will include the failling test's name. Such failures are usually caused by unexpected method calls on a mock.
NB: You would only need to use this where Testify mocks are used in tests that spawn goroutines, such as those run by the Terraform test driver.