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 RequireAnyCloudEnv(t *testing.T)
- func RequireCloudEnv(t *testing.T, cloudEnv 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 ¶
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 RequireAnyCloudEnv ¶ added in v1.2.0
func RequireCloudEnv ¶ added in v1.2.0
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 ¶
type CornerCase struct {
// contains filtered or unexported fields
}
func CornerCaseAccountID ¶ added in v1.2.0
func CornerCaseAccountID(id string) CornerCase
func CornerCaseExpectError ¶
func CornerCaseExpectError(msg string) CornerCase
func CornerCaseID ¶
func CornerCaseID(id string) CornerCase
func CornerCaseSkipCRUD ¶
func CornerCaseSkipCRUD(method string) CornerCase
type HTTPFixture ¶
type HTTPFixture struct { Method string Resource string Response any Status int ExpectedRequest any 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]any // 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 AccountID string 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 ¶
func (f ResourceFixture) ApplyAndExpectData(t *testing.T, data map[string]any)
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