qa

package
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPFailures = []HTTPFixture{
	{
		MatchAny:     true,
		ReuseRequest: true,
		Status:       418,
		Response: common.APIError{
			ErrorCode:  "NONSENSE",
			StatusCode: 418,
			Message:    "I'm a teapot",
		},
	},
}

Functions

func AssertErrorStartsWith

func AssertErrorStartsWith(t *testing.T, err error, message string) bool

AssertErrorStartsWith ..

func FirstKeyValue

func FirstKeyValue(t *testing.T, str, key string) string

FirstKeyValue gets it from HCL string

func GetEnvOrSkipTest

func GetEnvOrSkipTest(t *testing.T, name string) string

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 RandomEmail

func RandomEmail() string

RandomEmail generates random email

func RandomLongName

func RandomLongName() string

RandomLongName ...

func RandomName

func RandomName(prefix ...string) string

RandomName gives random name with optional prefix. e.g. qa.RandomName("tf-")

func RequireAnyCloudEnv added in v1.2.0

func RequireAnyCloudEnv(t *testing.T)

func RequireCloudEnv added in v1.2.0

func RequireCloudEnv(t *testing.T, cloudEnv string)

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL