Documentation
¶
Index ¶
- Variables
- func AssertErrorStartsWith(t *testing.T, err error, message string) bool
- func FirstKeyValue(t *testing.T, str, key string) string
- func GetEnvOrSkipTest(t *testing.T, name string) string
- func HTTPFixturesApply(t *testing.T, fixtures []HTTPFixture, ...)
- func HttpFixtureClient(t *testing.T, fixtures []HTTPFixture) (client *common.DatabricksClient, server *httptest.Server, err error)
- func HttpFixtureClientWithToken(t *testing.T, fixtures []HTTPFixture, token string) (client *common.DatabricksClient, server *httptest.Server, err error)
- func RandomEmail() string
- func RandomLongName() string
- func RandomName(prefix ...string) string
- func ResourceCornerCases(t *testing.T, resource *schema.Resource, cc ...CornerCase)
- type CornerCase
- type HTTPFixture
- type ResourceFixture
Constants ¶
This section is empty.
Variables ¶
var HTTPFailures = []HTTPFixture{ { MatchAny: true, ReuseRequest: true, Status: 418, Response: common.APIError{ ErrorCode: "NONSENSE", StatusCode: 418, Message: "I'm a teapot", }, }, }
Functions ¶
func AssertErrorStartsWith ¶
AssertErrorStartsWith ..
func FirstKeyValue ¶
FirstKeyValue gets it from HCL string
func GetEnvOrSkipTest ¶
GetEnvOrSkipTest proceeds with test only with that env variable
func HTTPFixturesApply ¶
func HTTPFixturesApply(t *testing.T, fixtures []HTTPFixture, callback func(ctx context.Context, client *common.DatabricksClient))
HTTPFixturesApply is a helper method
func HttpFixtureClient ¶
func HttpFixtureClient(t *testing.T, fixtures []HTTPFixture) (client *common.DatabricksClient, server *httptest.Server, err error)
HttpFixtureClient creates client for emulated HTTP server
func HttpFixtureClientWithToken ¶ added in v0.3.11
func HttpFixtureClientWithToken(t *testing.T, fixtures []HTTPFixture, token string) (client *common.DatabricksClient, server *httptest.Server, err error)
HttpFixtureClientWithToken creates client for emulated HTTP server
func RandomName ¶
RandomName gives random name with optional prefix. e.g. qa.RandomName("tf-")
func ResourceCornerCases ¶
func ResourceCornerCases(t *testing.T, resource *schema.Resource, cc ...CornerCase)
ResourceCornerCases checks for corner cases of error handling. Optional field name used to create error
Types ¶
type CornerCase ¶ added in v0.3.9
type CornerCase struct {
// contains filtered or unexported fields
}
func CornerCaseExpectError ¶ added in v0.3.9
func CornerCaseExpectError(msg string) CornerCase
func CornerCaseID ¶ added in v0.3.9
func CornerCaseID(id string) CornerCase
func CornerCaseSkipCRUD ¶ added in v0.3.9
func CornerCaseSkipCRUD(method string) CornerCase
type HTTPFixture ¶
type HTTPFixture struct { Method string Resource string Response interface{} Status int ExpectedRequest interface{} ReuseRequest bool MatchAny bool }
HTTPFixture defines request structure for test
func UnionFixturesLists ¶
func UnionFixturesLists(fixturesLists ...[]HTTPFixture) (fixtureList []HTTPFixture)
UnionFixturesLists merges two HTTP fixture lists together
type ResourceFixture ¶
type ResourceFixture struct { Fixtures []HTTPFixture Resource *schema.Resource RequiresNew bool InstanceState map[string]string State map[string]interface{} // HCL might be useful to test nested blocks HCL string CommandMock common.CommandMock Create bool Read bool Update bool Delete bool Removed bool ID string NonWritable bool Azure bool AzureSPN bool Gcp bool Token string // new resource New bool }
ResourceFixture helps testing resources and commands
func (ResourceFixture) Apply ¶
func (f ResourceFixture) Apply(t *testing.T) (*schema.ResourceData, error)
Apply runs tests from fixture
func (ResourceFixture) ApplyAndExpectData ¶ added in v0.4.6
func (f ResourceFixture) ApplyAndExpectData(t *testing.T, data map[string]interface{})
ApplyAndExpectData is a convenience method for tests that doesn't expect error, but want to check data
func (ResourceFixture) ApplyNoError ¶
func (f ResourceFixture) ApplyNoError(t *testing.T)
ApplyNoError is a convenience method for no-data tests
func (ResourceFixture) ExpectError ¶
func (f ResourceFixture) ExpectError(t *testing.T, msg string)
ExpectError passes if there's an error