Documentation
¶
Index ¶
- Variables
- func CompareTags(t assert.TestingT, expectedTags, actualTags []*core.MappingNode, ...)
- func NewTestLinkContext(providerConfigMap map[string]map[string]*core.ScalarValue, ...) provider.LinkContext
- func NewTestProviderContext(providerName string, providerConfig map[string]*core.ScalarValue, ...) provider.Context
- func RunLinkChangeStagingTestCases[ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ...](testCases []..., createLink func(linkServiceDeps ...) provider.Link, ...)
- func RunLinkUpdateIntermediaryResourcesTestCases[ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ...](testCases []..., createLink func(linkServiceDeps ...) provider.Link, ...)
- func RunLinkUpdateResourceTestCases[ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ...](testCases []..., createLink func(linkServiceDeps ...) provider.Link, ...)
- func RunResourceDeployTestCases[ServiceConfig any, Service any](testCases []ResourceDeployTestCase[ServiceConfig, Service], ...)
- func RunResourceDestroyTestCases[ServiceConfig any, Service any](testCases []ResourceDestroyTestCase[ServiceConfig, Service], ...)
- func RunResourceGetExternalStateTestCases[ServiceConfig any, Service any](testCases []ResourceGetExternalStateTestCase[ServiceConfig, Service], ...)
- func RunResourceHasStabilisedTestCases[ServiceConfig any, Service any](testCases []ResourceHasStabilisedTestCase[ServiceConfig, Service], ...)
- type EqualityCheckValues
- type LinkChangeStagingTestCase
- type LinkUpdateIntermediaryResourcesTestCase
- type LinkUpdateResource
- type LinkUpdateResourceTestCase
- type MockCalls
- func (m *MockCalls) AssertCalled(s *suite.Suite, methodName string)
- func (m *MockCalls) AssertCalledWith(s *suite.Suite, methodName string, callIndex int, args ...any)
- func (m *MockCalls) AssertNotCalled(s *suite.Suite, methodName string)
- func (m *MockCalls) RegisterCall(args ...any)
- func (m *MockCalls) RegisterNamedCall(methodName string, args ...any)
- type ResourceDeployTestCase
- type ResourceDestroyTestCase
- type ResourceGetExternalStateTestCase
- type ResourceHasStabilisedTestCase
- type TagFieldNames
Constants ¶
This section is empty.
Variables ¶
var Any = anyType{}
Any is a placeholder value for any value that can be used in assertions for method calls for a value that can be ignored.
Functions ¶
func CompareTags ¶
func CompareTags( t assert.TestingT, expectedTags, actualTags []*core.MappingNode, tagFieldNames *TagFieldNames, )
CompareTags compares two slices of tag MappingNodes in an order-independent way. It extracts key-value pairs represented as an object with attributes holding a key and a value that are both expected to be strings.
If nil is passed for tagFieldNames, it defaults to using "key" and "value" as the field names.
func NewTestLinkContext ¶
func NewTestLinkContext( providerConfigMap map[string]map[string]*core.ScalarValue, contextVariables map[string]*core.ScalarValue, ) provider.LinkContext
NewTestLinkContext creates a provider.LinkContext for testing purposes.
func NewTestProviderContext ¶
func NewTestProviderContext( providerName string, providerConfig map[string]*core.ScalarValue, contextVariables map[string]*core.ScalarValue, ) provider.Context
NewTestProviderContext creates a provider.Context for tests.
func RunLinkChangeStagingTestCases ¶
func RunLinkChangeStagingTestCases[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ]( testCases []LinkChangeStagingTestCase[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], createLink func( linkServiceDeps pluginutils.LinkServiceDeps[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], ) provider.Link, testSuite *suite.Suite, )
func RunLinkUpdateIntermediaryResourcesTestCases ¶
func RunLinkUpdateIntermediaryResourcesTestCases[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ]( testCases []LinkUpdateIntermediaryResourcesTestCase[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], createLink func( linkServiceDeps pluginutils.LinkServiceDeps[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], ) provider.Link, testSuite *suite.Suite, )
RunLinkUpdateIntermediaryResourcesTestCases runs a set of test cases for the `UpdateIntermediaryResources“ methods of a link implementation in a provider plugin.
func RunLinkUpdateResourceTestCases ¶
func RunLinkUpdateResourceTestCases[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ]( testCases []LinkUpdateResourceTestCase[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], createLink func( linkServiceDeps pluginutils.LinkServiceDeps[ ResourceAServiceConfig, ResourceAService, ResourceBServiceConfig, ResourceBService, ], ) provider.Link, testSuite *suite.Suite, )
RunLinkUpdateResourceTestCases runs a set of test cases for the `UpdateResource(A|B)` methods of a link implementation in a provider plugin.
func RunResourceDeployTestCases ¶
func RunResourceDeployTestCases[ServiceConfig any, Service any]( testCases []ResourceDeployTestCase[ServiceConfig, Service], createResource func( serviceFactory pluginutils.ServiceFactory[ServiceConfig, Service], configStore pluginutils.ServiceConfigStore[ServiceConfig], ) provider.Resource, testSuite *suite.Suite, )
RunResourceDeployTestCases runs a set of test cases for the `Deploy` method of a resource implementation in a provider plugin.
func RunResourceDestroyTestCases ¶
func RunResourceDestroyTestCases[ServiceConfig any, Service any]( testCases []ResourceDestroyTestCase[ServiceConfig, Service], createResource func( serviceFactory pluginutils.ServiceFactory[ServiceConfig, Service], configStore pluginutils.ServiceConfigStore[ServiceConfig], ) provider.Resource, testSuite *suite.Suite, )
RunResourceDestroyTestCases runs a set of test cases for the `Destroy` method of a resource implementation in a provider plugin.
func RunResourceGetExternalStateTestCases ¶
func RunResourceGetExternalStateTestCases[ServiceConfig any, Service any]( testCases []ResourceGetExternalStateTestCase[ServiceConfig, Service], createResource func( serviceFactory pluginutils.ServiceFactory[ServiceConfig, Service], configStore pluginutils.ServiceConfigStore[ServiceConfig], ) provider.Resource, testSuite *suite.Suite, )
RunResourceGetExternalStateTestCases runs a set of test cases for the `GetExternalState` method of a resource implementation in a provider plugin.
func RunResourceHasStabilisedTestCases ¶
func RunResourceHasStabilisedTestCases[ServiceConfig any, Service any]( testCases []ResourceHasStabilisedTestCase[ServiceConfig, Service], createResource func( serviceFactory pluginutils.ServiceFactory[ServiceConfig, Service], configStore pluginutils.ServiceConfigStore[ServiceConfig], ) provider.Resource, testSuite *suite.Suite, )
RunResourceHasStabilisedTestCases runs a set of test cases for the `HasStabilised` method of a resource implementation in a provider plugin.
Types ¶
type EqualityCheckValues ¶
EqualityCheckValues is a struct used to hold expected and actual values for equality checks in assertions used with an `equality` matcher that takes an arg and transforms ito to be a value that can be compared with an expected value.
type LinkChangeStagingTestCase ¶
type LinkChangeStagingTestCase[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ] struct { // The name of the test case used for errors and debugging. Name string // ServiceFactoryA is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the first resource (resource A). // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactoryA pluginutils.ServiceFactory[ResourceAServiceConfig, ResourceAService] // ServiceFactoryB is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the second resource (resource B). // // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // For example the `ServiceConfig` type parameter would be `*aws.Config` for // AWS services and the `Service` type parameter could be a `lambda.Service` // interface that implements API methods for the AWS Lambda service. ServiceFactoryB pluginutils.ServiceFactory[ResourceBServiceConfig, ResourceBService] // ConfigStoreA is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the first resource (resource A). // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if your service factory requires a specific // configuration struct to be able to create an instance of the service. ConfigStoreA pluginutils.ServiceConfigStore[ResourceAServiceConfig] // ConfigStoreB is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the second resource (resource B). ConfigStoreB pluginutils.ServiceConfigStore[ResourceBServiceConfig] // Input for the link stage changing operation. Input *provider.LinkStageChangesInput // Expected output from the link stage changing operation. ExpectedOutput *provider.LinkStageChangesOutput // If true, the test case expects an error to be returned. ExpectError bool // The expected error message if an error is expected. // This doesn't have to be an exact match, the error message // just needs to contain the provided string. ExpectedErrorMessage string }
LinkChangeStagingTestCase defines a test case for link change staging.
type LinkUpdateIntermediaryResourcesTestCase ¶
type LinkUpdateIntermediaryResourcesTestCase[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ] struct { // The name of the test case used for errors and debugging. Name string // ServiceFactoryA is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the first resource (resource A). // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactoryA pluginutils.ServiceFactory[ResourceAServiceConfig, ResourceAService] // ServiceFactoryB is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the second resource (resource B). // // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // For example the `ServiceConfig` type parameter would be `*aws.Config` for // AWS services and the `Service` type parameter could be a `lambda.Service` // interface that implements API methods for the AWS Lambda service. ServiceFactoryB pluginutils.ServiceFactory[ResourceBServiceConfig, ResourceBService] // ConfigStoreA is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the first resource (resource A). // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if the service factory for resource A requires a specific // configuration struct to be able to create an instance of the service. ConfigStoreA pluginutils.ServiceConfigStore[ResourceAServiceConfig] // ConfigStoreB is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the second resource (resource B). // This is only needed if the service factory for resource B requires a specific // configuration struct to be able to create an instance of the service. ConfigStoreB pluginutils.ServiceConfigStore[ResourceBServiceConfig] // IntermediariesServiceMockCalls is a mock calls tracker that is expected to be embedded // into a mock implementation of the service interface for carrying out // the update operation via the provider service APIs for intermediary resources. // // This is optional and only needs to be set if the test case // uses mocks instead of a real service. IntermediariesServiceMockCalls *MockCalls // Input for the link intermediary resources update operation. Input *provider.LinkUpdateIntermediaryResourcesInput // Expected output from the link intermediary resources update operation. ExpectedOutput *provider.LinkUpdateIntermediaryResourcesOutput // ExpectedOutputMatcher is a function that takes the actual output // from the `UpdateIntermediaryResources` method and returns a prepared actual // value along with the expected value to be used in an equality check. ExpectedOutputMatcher func( actual *provider.LinkUpdateIntermediaryResourcesOutput, ) (EqualityCheckValues, error) // ExtraAssertions is an optional function that is called after the output of // the operation successfully matches the expected output or matcher. // This is useful for adding additional assertions, such as checking // the persisted state of intermediary resources in the upstream service // for integration tests. ExtraAssertions func( ctx context.Context, suite *suite.Suite, output *provider.LinkUpdateIntermediaryResourcesOutput, ) // UpdateActionsCalled is a mapping of method name to the // expected second argument for the method. // When the value is a slice of any, it is expected that the method // is called multiple times with different arguments in the provided order. // This will usually be something like a `*Input` or `*Request` struct // that service library functions take after a context argument. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `IntermediariesServiceMockCalls` is set). UpdateActionsCalled map[string]any // UpdateActionsNotCalled is a list of method names // that are not expected to be called as a part // of the update operation. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `IntermediariesServiceMockCalls` is set). UpdateActionsNotCalled []string // If true, the test case expects an error to be returned. ExpectError bool // The expected error message if an error is expected. // This doesn't have to be an exact match, the error message // just needs to contain the provided string. ExpectedErrorMessage string // Cleanup is a function that is called after the test case has run. // This is used to clean up intermediary resources that were created for the link test case. // This is useful for integration tests with real services where the resource // needs to be cleaned up after the test case has run regardless of whether // the test case passes or fails. Cleanup func( ctx context.Context, failed bool, output *provider.LinkUpdateIntermediaryResourcesOutput, ) error }
LinkUpdateIntermediaryResourcesTestCase defines a test case for updating intermediary resources in a link.
type LinkUpdateResource ¶
type LinkUpdateResource string
LinkUpdateResource is a type that represents a resource that should be updated in a link update operation.
const ( // LinkUpdateResourceA is used to select "resource A" in a link // update operation for testing purposes. LinkUpdateResourceA LinkUpdateResource = "resourceA" // LinkUpdateResourceB is used to select "resource B" in a link // update operation for testing purposes. LinkUpdateResourceB LinkUpdateResource = "resourceB" )
type LinkUpdateResourceTestCase ¶
type LinkUpdateResourceTestCase[ ResourceAServiceConfig any, ResourceAService any, ResourceBServiceConfig any, ResourceBService any, ] struct { // The name of the test case used for errors and debugging. Name string // ServiceFactoryA is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the first resource (resource A). // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactoryA pluginutils.ServiceFactory[ResourceAServiceConfig, ResourceAService] // ServiceFactoryB is a function that creates an instance of the service // using the provided service-specific configuration and a provider context // for the second resource (resource B). // // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // For example the `ServiceConfig` type parameter would be `*aws.Config` for // AWS services and the `Service` type parameter could be a `lambda.Service` // interface that implements API methods for the AWS Lambda service. ServiceFactoryB pluginutils.ServiceFactory[ResourceBServiceConfig, ResourceBService] // ConfigStoreA is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the first resource (resource A). // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if the service factory for resource A requires a specific // configuration struct to be able to create an instance of the service. ConfigStoreA pluginutils.ServiceConfigStore[ResourceAServiceConfig] // ConfigStoreB is a store that generates service-specific configuration // for the service factory to create an instance of the service // for the second resource (resource B). // This is only needed if the service factory for resource B requires a specific // configuration struct to be able to create an instance of the service. ConfigStoreB pluginutils.ServiceConfigStore[ResourceBServiceConfig] // CurrentServiceMockCalls is a mock calls tracker that is expected to be embedded // into a mock implementation of the service interface for carrying out // the update operation via the provider service APIs for the resource // under test. // // This is optional and only needs to be set if the test case // uses mocks instead of a real service. CurrentServiceMockCalls *MockCalls // Input for the link resource update operation. Input *provider.LinkUpdateResourceInput // Expected output from the link resource update operation. ExpectedOutput *provider.LinkUpdateResourceOutput // ExpectedOutputMatcher is a function that takes the actual output // from the `UpdateResource(A|B)` method and returns a prepared actual // value along with the expected value to be used in an equality check. ExpectedOutputMatcher func( actual *provider.LinkUpdateResourceOutput, ) (EqualityCheckValues, error) // ExtraAssertions is an optional function that is called after the output of // the operation successfully matches the expected output or matcher. // This is useful for adding additional assertions, such as checking // the persisted state of the resource in the upstream service for integration tests. ExtraAssertions func( ctx context.Context, suite *suite.Suite, output *provider.LinkUpdateResourceOutput, ) // Resource defines the resource in the link relationship that should be updated. Resource LinkUpdateResource // UpdateActionsCalled is a mapping of method name to the // expected second argument for the method. // When the value is a slice of any, it is expected that the method // is called multiple times with different arguments in the provided order. // This will usually be something like a `*Input` or `*Request` struct // that service library functions take after a context argument. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `CurrentServiceMockCalls` is set). UpdateActionsCalled map[string]any // UpdateActionsNotCalled is a list of method names // that are not expected to be called as a part // of the update operation. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `CurrentServiceMockCalls` is set). UpdateActionsNotCalled []string // If true, the test case expects an error to be returned. ExpectError bool // The expected error message if an error is expected. // This doesn't have to be an exact match, the error message // just needs to contain the provided string. ExpectedErrorMessage string // Cleanup is a function that is called after the test case has run. // This is used to clean up resources that were created for the link test case. // This is useful for integration tests with real services where the resource // needs to be cleaned up after the test case has run regardless of whether // the test case passes or fails. Cleanup func(ctx context.Context, failed bool, output *provider.LinkUpdateResourceOutput) error }
LinkUpdateResourceTestCase defines a test case for link resource update operations.
type MockCalls ¶
type MockCalls struct {
// contains filtered or unexported fields
}
MockCalls is a lightweight test helper for tracking calls to methods in a mock implementation of an upstream provider service interface. This can be embedded in a service-specific mock struct to track calls to methods and make assertions on them in tests. This struct is safe for concurrent use when multiple calls are made across goroutines at the same time.
Example:
type MyServiceMock struct {
MockCalls
// Other fields specific to the mock service
}
// Other methods specific to the mock service
func (m *MyServiceMock) MyMethod(arg1 string, arg2 int) {
m.RegisterCall(arg1, arg2)
// Implementation of the method
}
func (*MockCalls) AssertCalled ¶
AssertCalled asserts that a method with the given name was called at least once.
func (*MockCalls) AssertCalledWith ¶
AssertCalledWith asserts that a method with the given name was called with the specific arguments for the provided call index (callNumber - 1).
func (*MockCalls) AssertNotCalled ¶
AssertNotCalled asserts that a method with the given name was not called. This is useful to ensure that a method was not invoked during a test.
func (*MockCalls) RegisterCall ¶
RegisterCall registers a call for the current method with the given arguments.
func (*MockCalls) RegisterNamedCall ¶
RegisterNamedCall registers a call to a method with the given name.
type ResourceDeployTestCase ¶
type ResourceDeployTestCase[ServiceConfig any, Service any] struct { // Name is the name of the test case that will be used when running a test suite. Name string // ServiceFactory is a function that creates an instance of the service // using the provided service-specific configuration and a provider context. // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactory pluginutils.ServiceFactory[ServiceConfig, Service] // ServiceMockCalls is a mock calls tracker that is expected to be embedded // into a mock implementation of the service interface for carrying out // the save operation via the provider service APIs. // // This is optional and only needs to be set if the test case // uses mocks instead of a real service. ServiceMockCalls *MockCalls // ConfigStore is a store that generates service-specific configuration // for the service factory to create an instance of the service. // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if your service factory requires a specific // configuration struct to be able to create an instance of the service. ConfigStore pluginutils.ServiceConfigStore[ServiceConfig] // Input is passed into the `Deploy` method of the resource implementation. Input *provider.ResourceDeployInput // SaveActionsCalled is a mapping of method name to the // expected second argument for the method. // When the value is a slice of any, it is expected that the method // is called multiple times with different arguments in the provided order. // This will usually be something like a `*Input` or `*Request` struct // that service library functions take after a context argument. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `ServiceMockCalls` is set). SaveActionsCalled map[string]any // SaveActionsNotCalled is a list of method names // that are not expected to be called as a part // of the save operation. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `ServiceMockCalls` is set). SaveActionsNotCalled []string // ExpectedOutput is the expected output from the `Deploy` method. ExpectedOutput *provider.ResourceDeployOutput // ExpectedOutputMatcher is a function that takes the actual output // from the `Deploy` method and returns a prepared actual // value along with the expected value to be used in an equality check. ExpectedOutputMatcher func( actual *provider.ResourceDeployOutput, ) (EqualityCheckValues, error) // ExtraAssertions is an optional function that is called after the output of // the operation successfully matches the expected output or matcher. // This is useful for adding additional assertions, such as checking // the persisted state of the resource in the upstream service for integration tests. ExtraAssertions func( ctx context.Context, suite *suite.Suite, output *provider.ResourceDeployOutput, ) // ExpectError indicates whether the test case expects an error // to be returned from the `Deploy` method. ExpectError bool // Cleanup is a function that is called after the test case has run. // This is used to clean up any resources that were created during the test case. // This is useful for integration tests with real services where the resource // needs to be cleaned up after the test case has run regardless of whether // the test case passes or fails. Cleanup func(ctx context.Context, output *provider.ResourceDeployOutput) error }
ResourceDeployTestCase defines a test case for the `Deploy` method of a resource implementation in a provider plugin. This is used to test both creation and update operations which may be two separate methods depending on the provider plugin implementation.
For resources defined with the `providerv1.ResourceDefinition` helper struct, this test case will be used to test both `Create` and `Update` methods as the `Deploy` method in the helper struct will determine the appropriate action to take based on the deploy input.
type ResourceDestroyTestCase ¶
type ResourceDestroyTestCase[ServiceConfig any, Service any] struct { // Name is the name of the test case that will be used when running a test suite. Name string // ServiceFactory is a function that creates an instance of the service // using the provided service-specific configuration and a provider context. // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactory pluginutils.ServiceFactory[ServiceConfig, Service] // ServiceMockCalls is a mock calls tracker that is expected to be embedded // into a mock implementation of the service interface for carrying out // the destroy operation via the provider service APIs. // // This is optional and only needs to be set if the test case // uses mocks instead of a real service. ServiceMockCalls *MockCalls // ConfigStore is a store that generates service-specific configuration // for the service factory to create an instance of the service. // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if your service factory requires a specific // configuration struct to be able to create an instance of the service. ConfigStore pluginutils.ServiceConfigStore[ServiceConfig] // Input is passed into the `Destroy` method of the resource implementation. Input *provider.ResourceDestroyInput // DestroyActionsCalled is a mapping of method name to the // expected second argument for the method. // When the value is a slice of any, it is expected that the method // is called multiple times with different arguments in the provided order. // This will usually be something like a `*Input` or `*Request` struct // that service library functions take after a context argument. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `ServiceMockCalls` is set). DestroyActionsCalled map[string]any // SaveActionsNotCalled is a list of method names // that are not expected to be called as a part // of the save operation. // // This should only be set if the case uses mocks instead of a real service // (i.e. when `ServiceMockCalls` is set). DestroyActionsNotCalled []string // ExpectError indicates whether the test case expects an error // to be returned from the `Destroy` method. ExpectError bool }
ResourceDestroyTestCase defines a test case for the `Destroy` method of a resource implementation in a provider plugin. This is used to test both creation and update operations which may be two separate methods depending on the provider plugin implementation.
type ResourceGetExternalStateTestCase ¶
type ResourceGetExternalStateTestCase[ServiceConfig any, Service any] struct { // Name is the name of the test case that will be used when running a test suite. Name string // ServiceFactory is a function that creates an instance of the service // using the provided service-specific configuration and a provider context. // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactory pluginutils.ServiceFactory[ServiceConfig, Service] // ConfigStore is a store that generates service-specific configuration // for the service factory to create an instance of the service. // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if your service factory requires a specific // configuration struct to be able to create an instance of the service. ConfigStore pluginutils.ServiceConfigStore[ServiceConfig] // Input is the input passed into the `GetExternalState` method. Input *provider.ResourceGetExternalStateInput // ExpectedOutput is the expected output from the `GetExternalState` method. ExpectedOutput *provider.ResourceGetExternalStateOutput // ExpectedOutputMatcher is a function that takes the actual output // from the `GetExternalState` method and returns a prepared actual // value along with the expected value to be used in an equality check. ExpectedOutputMatcher func( actual *provider.ResourceGetExternalStateOutput, ) (EqualityCheckValues, error) // CheckTags should be set to true if the subject resource holds tags // as an array of key-value pair objects. // The default behaviour is to not check tags. CheckTags bool // TagsFieldName is the name of the field in the resource spec state // that holds the tags as an array of key-value pair objects. // This field is used only if CheckTags is `true`. // The default value is "tags". TagsFieldName string // TagObjectFieldNames is used to specify the field names for keys and values // for tags in the resource spec state. // The default field names are "key" and "value", this will only // be used if CheckTags is `true`. TagObjectFieldNames *TagFieldNames // ExpectError indicates whether the test case expects an error // to be returned from the `GetExternalState` method. ExpectError bool }
ResourceGetExternalStateTestCase defines a test case for `GetExternalState` method of a resource implementation in a provider plugin.
type ResourceHasStabilisedTestCase ¶
type ResourceHasStabilisedTestCase[ServiceConfig any, Service any] struct { // Name is the name of the test case that will be used when running a test suite. Name string // ServiceFactory is a function that creates an instance of the service // using the provided service-specific configuration and a provider context. // serviceConfig can be nil for services that do not take a specific configuration // to create client instances. // // For example the `ServiceConfig` type parameter would be `*aws.Config` for AWS services // and the `Service` type parameter could be a `lambda.Service` interface that implements // API methods for the AWS Lambda service. // The `ServiceConfigStore` type parameter would be an optional store ServiceFactory pluginutils.ServiceFactory[ServiceConfig, Service] // ConfigStore is a store that generates service-specific configuration // for the service factory to create an instance of the service. // This could be something like a cache for `*aws.Config` for AWS services // based on a session ID. // This is only needed if your service factory requires a specific // configuration struct to be able to create an instance of the service. ConfigStore pluginutils.ServiceConfigStore[ServiceConfig] // Input is the input passed into the `HasStabilised` method. Input *provider.ResourceHasStabilisedInput // ExpectedOutput is the expected output from the `HasStabilised` method. ExpectedOutput *provider.ResourceHasStabilisedOutput // ExpectedOutputMatcher is a function that takes the actual output // from the `HasStabilised` method and returns a prepared actual // value along with the expected value to be used in an equality check. ExpectedOutputMatcher func( actual *provider.ResourceHasStabilisedOutput, ) (EqualityCheckValues, error) // ExpectError indicates whether the test case expects an error // to be returned from the `GetExternalState` method. ExpectError bool }
ResourceHasStabilisedTestCase defines a test case for `HasStabilised` method of a resource implementation in a provider plugin.
type TagFieldNames ¶
TagFieldNames holds the field names used to extract key and value from tag slice MappingNodes. By default, if empty or the values are not set when passed to CompareTags, it will use "key" and "value" as the field names.