Documentation
¶
Index ¶
- Constants
- func AssertDiagsOK(t *testing.T, diags diag.Diagnostics)
- func CaptureOrMockTestCaseAndRun(t *testing.T, config MockHTTPDataConfig, testCase *resource.TestCase)
- func ConfigYaml(capturedData *MockHTTPData) (string, error)
- func DownloadOpenAPISpec(url, specFilePath string) (err error)
- func ExtractConfigVariables(t *testing.T, config string) map[string]string
- func ExtractVersion(contentType string) (string, error)
- func ExtractVersionRequestResponse(headerValueRequest, headerValueResponse string) string
- func FailedFilename(filePath string) string
- func InitializeAPISpecPaths()
- func IsCapture() bool
- func IsDataUpdate() bool
- func IsReplay() bool
- func IsTfLogDebug() bool
- func MockConfigFilePath(t *testing.T) string
- func ReadAPISpecPaths() map[string][]APISpecPath
- func TFListValue(t *testing.T, elementType types.ObjectType, tfList any) types.List
- func TFObjectValue(t *testing.T, objType types.ObjectType, attributes any) types.Object
- func TestAccProviderV6FactoriesWithMock(t *testing.T, clientModifier HTTPClientModifier) map[string]func() (tfprotov6.ProviderServer, error)
- func UpdateMockDataDiffRequest(t *testing.T, stepIndex, diffRequestIndex int, newText string)
- func WriteConfigYaml(filePath, configYaml string) error
- type APISpecPath
- type CaptureMockConfigClientModifier
- func (c *CaptureMockConfigClientModifier) ConfigYaml() (string, error)
- func (c *CaptureMockConfigClientModifier) IncreaseStepNumber()
- func (c *CaptureMockConfigClientModifier) ModifyHTTPClient(httpClient *http.Client) error
- func (c *CaptureMockConfigClientModifier) NormalizeCapturedData()
- func (c *CaptureMockConfigClientModifier) ResetHTTPClient(httpClient *http.Client)
- func (c *CaptureMockConfigClientModifier) RoundTrip(req *http.Request) (*http.Response, error)
- func (c *CaptureMockConfigClientModifier) WriteCapturedData(filePath string) error
- type HTTPClientModifier
- type Literal
- type MockHTTPData
- func (m *MockHTTPData) AddRoundtrip(t *testing.T, rt *RoundTrip, isDiff bool) error
- func (m *MockHTTPData) Normalize()
- func (m *MockHTTPData) UpdateVariables(t *testing.T, variables map[string]string) error
- func (m *MockHTTPData) UpdateVariablesIgnoreChanges(t *testing.T, variables map[string]string) error
- type MockHTTPDataConfig
- type MockRoundTripper
- type OpenapiSchema
- type ProviderMocked
- func (p *ProviderMocked) Configure(ctx context.Context, req fwProvider.ConfigureRequest, ...)
- func (p *ProviderMocked) DataSources(ctx context.Context) []func() datasource.DataSource
- func (p *ProviderMocked) Metadata(ctx context.Context, req fwProvider.MetadataRequest, ...)
- func (p *ProviderMocked) Resources(ctx context.Context) []func() resource.Resource
- func (p *ProviderMocked) Schema(ctx context.Context, req fwProvider.SchemaRequest, ...)
- type RequestInfo
- type RoundTrip
- type TFConfigReplacementType
- type VariableChange
- type VariablesChangedError
Constants ¶
View Source
const ( EnvNameHTTPMockerCapture = "HTTP_MOCKER_CAPTURE" EnvNameHTTPMockerReplay = "HTTP_MOCKER_REPLAY" EnvNameHTTPMockerDataUpdate = "HTTP_MOCKER_DATA_UPDATE" )
Variables ¶
This section is empty.
Functions ¶
func AssertDiagsOK ¶
func AssertDiagsOK(t *testing.T, diags diag.Diagnostics)
func CaptureOrMockTestCaseAndRun ¶ added in v1.23.0
func CaptureOrMockTestCaseAndRun(t *testing.T, config MockHTTPDataConfig, testCase *resource.TestCase)
func ConfigYaml ¶ added in v1.23.0
func ConfigYaml(capturedData *MockHTTPData) (string, error)
func DownloadOpenAPISpec ¶ added in v1.23.0
func ExtractConfigVariables ¶ added in v1.23.0
func ExtractVersion ¶ added in v1.23.0
func ExtractVersionRequestResponse ¶ added in v1.23.0
func FailedFilename ¶ added in v1.23.0
func InitializeAPISpecPaths ¶ added in v1.23.0
func InitializeAPISpecPaths()
func IsDataUpdate ¶ added in v1.23.0
func IsDataUpdate() bool
func IsTfLogDebug ¶ added in v1.26.0
func IsTfLogDebug() bool
func MockConfigFilePath ¶ added in v1.23.0
func ReadAPISpecPaths ¶ added in v1.23.0
func ReadAPISpecPaths() map[string][]APISpecPath
func TFListValue ¶
func TFObjectValue ¶
func TestAccProviderV6FactoriesWithMock ¶ added in v1.23.0
func TestAccProviderV6FactoriesWithMock(t *testing.T, clientModifier HTTPClientModifier) map[string]func() (tfprotov6.ProviderServer, error)
func UpdateMockDataDiffRequest ¶ added in v1.23.0
func WriteConfigYaml ¶ added in v1.23.0
Types ¶
type APISpecPath ¶ added in v1.23.0
type APISpecPath struct {
Path string
}
func FindNormalizedPath ¶ added in v1.23.0
func FindNormalizedPath(path string, apiSpecPaths *[]APISpecPath) (APISpecPath, error)
func (*APISpecPath) Match ¶ added in v1.23.0
func (a *APISpecPath) Match(path string) bool
type CaptureMockConfigClientModifier ¶ added in v1.23.0
type CaptureMockConfigClientModifier struct {
// contains filtered or unexported fields
}
func NewCaptureMockConfigClientModifier ¶ added in v1.23.0
func NewCaptureMockConfigClientModifier(t *testing.T, config *MockHTTPDataConfig, data *MockHTTPData) *CaptureMockConfigClientModifier
func (*CaptureMockConfigClientModifier) ConfigYaml ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) ConfigYaml() (string, error)
func (*CaptureMockConfigClientModifier) IncreaseStepNumber ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) IncreaseStepNumber()
func (*CaptureMockConfigClientModifier) ModifyHTTPClient ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) ModifyHTTPClient(httpClient *http.Client) error
func (*CaptureMockConfigClientModifier) NormalizeCapturedData ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) NormalizeCapturedData()
func (*CaptureMockConfigClientModifier) ResetHTTPClient ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) ResetHTTPClient(httpClient *http.Client)
func (*CaptureMockConfigClientModifier) WriteCapturedData ¶ added in v1.23.0
func (c *CaptureMockConfigClientModifier) WriteCapturedData(filePath string) error
type HTTPClientModifier ¶ added in v1.23.0
type Literal ¶ added in v1.23.0
type Literal string
There is an issue when dumping the yaml, if the \n \n sequence is found it will always dump using the DoubleQuotedStyle, workaround by using this custom dumping.
func (Literal) MarshalYAML ¶ added in v1.23.0
type MockHTTPData ¶ added in v1.23.0
type MockHTTPData struct { Variables map[string]string `yaml:"variables"` Steps []stepRequests `yaml:"steps"` }
func NewMockHTTPData ¶ added in v1.23.0
func NewMockHTTPData(t *testing.T, stepCount int, tfConfigs []string) *MockHTTPData
func ParseTestDataConfigYAML ¶ added in v1.23.0
func ParseTestDataConfigYAML(filePath string) (*MockHTTPData, error)
func ReadMockData ¶ added in v1.23.0
func ReadMockData(t *testing.T, tfConfigs []string) *MockHTTPData
func (*MockHTTPData) AddRoundtrip ¶ added in v1.23.0
func (*MockHTTPData) Normalize ¶ added in v1.23.0
func (m *MockHTTPData) Normalize()
Normalize happens after all data is captured, as a cluster.name might only be discovered as a variable in later steps
func (*MockHTTPData) UpdateVariables ¶ added in v1.23.0
func (*MockHTTPData) UpdateVariablesIgnoreChanges ¶ added in v1.23.0
type MockHTTPDataConfig ¶ added in v1.23.0
type MockHTTPDataConfig struct { SideEffect func() error IsDiffSkipSuffixes []string IsDiffMustSubstrings []string QueryVars []string AllowMissingRequests bool AllowOutOfOrder bool }
func (MockHTTPDataConfig) WithAllowOutOfOrder ¶ added in v1.23.0
func (c MockHTTPDataConfig) WithAllowOutOfOrder() MockHTTPDataConfig
type MockRoundTripper ¶ added in v1.23.0
type MockRoundTripper struct {
// contains filtered or unexported fields
}
func NewMockRoundTripper ¶ added in v1.23.0
func NewMockRoundTripper(t *testing.T, config *MockHTTPDataConfig, data *MockHTTPData) (http.RoundTripper, *MockRoundTripper)
func (*MockRoundTripper) CheckStepRequests ¶ added in v1.23.0
func (r *MockRoundTripper) CheckStepRequests(_ *terraform.State) error
func (*MockRoundTripper) IncreaseStepNumberAndInit ¶ added in v1.23.0
func (r *MockRoundTripper) IncreaseStepNumberAndInit()
type OpenapiSchema ¶ added in v1.23.0
type ProviderMocked ¶ added in v1.23.0
type ProviderMocked struct { OriginalProvider *provider.MongodbtlasProvider ClientModifier HTTPClientModifier // contains filtered or unexported fields }
func (*ProviderMocked) Configure ¶ added in v1.23.0
func (p *ProviderMocked) Configure(ctx context.Context, req fwProvider.ConfigureRequest, resp *fwProvider.ConfigureResponse)
func (*ProviderMocked) DataSources ¶ added in v1.23.0
func (p *ProviderMocked) DataSources(ctx context.Context) []func() datasource.DataSource
func (*ProviderMocked) Metadata ¶ added in v1.23.0
func (p *ProviderMocked) Metadata(ctx context.Context, req fwProvider.MetadataRequest, resp *fwProvider.MetadataResponse)
func (*ProviderMocked) Resources ¶ added in v1.23.0
func (p *ProviderMocked) Resources(ctx context.Context) []func() resource.Resource
func (*ProviderMocked) Schema ¶ added in v1.23.0
func (p *ProviderMocked) Schema(ctx context.Context, req fwProvider.SchemaRequest, resp *fwProvider.SchemaResponse)
type RequestInfo ¶ added in v1.23.0
type RequestInfo struct { Path string `yaml:"path"` Method string `yaml:"method"` Version string `yaml:"version"` Text string `yaml:"text"` Responses []statusText `yaml:"responses"` }
func (RequestInfo) MarshalYAML ¶ added in v1.23.0
func (i RequestInfo) MarshalYAML() (any, error)
Custom marshaling is necessary to use `flow` style only on response fields (text and responses.*.text)
func (*RequestInfo) Match ¶ added in v1.23.0
func (i *RequestInfo) Match(t *testing.T, method, version string, reqURL *url.URL, mockData *MockHTTPData) bool
func (*RequestInfo) NormalizePath ¶ added in v1.23.0
func (i *RequestInfo) NormalizePath(reqURL *url.URL) string
func (*RequestInfo) QueryVars ¶ added in v1.23.0
func (i *RequestInfo) QueryVars() []string
type RoundTrip ¶ added in v1.23.0
type RoundTrip struct { Variables map[string]string QueryString string Request RequestInfo Response statusText StepNumber int }
type TFConfigReplacementType ¶ added in v1.23.0
type TFConfigReplacementType int
const (
TFConfigReplacementString TFConfigReplacementType = iota
)
type VariableChange ¶ added in v1.23.0
type VariablesChangedError ¶ added in v1.23.0
type VariablesChangedError struct {
Changes []VariableChange
}
func (VariablesChangedError) ChangedNamesMap ¶ added in v1.23.0
func (e VariablesChangedError) ChangedNamesMap() map[string]string
func (VariablesChangedError) ChangedValuesMap ¶ added in v1.23.0
func (e VariablesChangedError) ChangedValuesMap() map[string]string
func (VariablesChangedError) Error ¶ added in v1.23.0
func (e VariablesChangedError) Error() string
Click to show internal directories.
Click to hide internal directories.