Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RecoverPanicString = "\t--- PANIC ON ERROR:"
Functions ¶
func CreateAWSError ¶
func CreateAWSError(awsError ServiceAPIError) awserr.RequestFailure
CreateAWSError is used for mocking the types of errors received from aws-sdk-go so that the expected code path executes. Support for specifying the HTTP status code and request ID can be added in the future if needed
func LoadFromFixture ¶
func LoadFromFixture( fixturePath string, output interface{}, )
LoadFromFixture fills an empty pointer variable with the data from a fixture JSON/YAML file.
Types ¶
type Expect ¶
type Expect struct { LatestState string `json:"latest_state"` // Error is a string matching the message of the expected error returned from the ResourceManager operation. // Possible errors can be found in runtime/pkg/errors/error.go Error string `json:"error"` }
Expect represents test scenario expected outcome fixture to load from file path
type Fixture ¶
type Fixture struct { // DesiredState lets you specify fixture path to load the desired state fixture DesiredState string `json:"desired_state"` // LatestState lets you specify fixture path to load the current state fixture LatestState string `json:"latest_state"` // ServiceAPIs lets you specify fixture path to mock service sdk api response ServiceAPIs []ServiceAPI `json:"svc_api"` }
Fixture represents test scenario fixture to load from file paths
type ServiceAPI ¶
type ServiceAPI struct { Operation string `json:"operation"` Output string `json:"output_fixture,omitempty"` ServiceAPIError *ServiceAPIError `json:"error,omitempty"` }
ServiceAPI represents details about the the service sdk api and fixture path to mock its response
type ServiceAPIError ¶
type ServiceAPIError struct { // Code here is usually the type of fault/error, not the HTTP status code Code string `json:"code"` Message string `json:"message"` }
ServiceAPIError contains the specification for the error of the mock API response
type TestConfig ¶
type TestConfig struct { Name string `json:"name"` Description string `json:"description"` Scenarios []TestScenario `json:"scenarios"` }
TestConfig represents declarative unit test
type TestRunnerDelegate ¶
type TestRunnerDelegate interface { ResourceDescriptor() acktypes.AWSResourceDescriptor Equal(desired acktypes.AWSResource, latest acktypes.AWSResource) bool // remove it when ResourceDescriptor.Delta() is available ResourceManager(*mocksvcsdkapi.ApplicationAutoScalingAPI) acktypes.AWSResourceManager EmptyServiceAPIOutput(apiName string) (interface{}, error) GoTestRunner() *testing.T }
TestRunnerDelegate provides interface for custom resource tests to implement. TestSuiteRunner depends on it to run tests for custom resource.
type TestScenario ¶
type TestScenario struct { Name string `json:"name"` Description string `json:"description"` // Fixture lets you specify test scenario given input fixtures Fixture Fixture `json:"given"` // UnitUnderTest lets you specify the unit to test // For example resource manager API: ReadOne, Create, Update, Delete UnitUnderTest string `json:"invoke"` // Expect lets you specify test scenario expected outcome fixtures Expect Expect `json:"expect"` }
TestScenario represents declarative test scenario details
type TestSuite ¶
type TestSuite struct {
Tests []TestConfig `json:"tests"`
}
TestSuite represents instructions to run unit tests using test fixtures and mock service apis
type TestSuiteRunner ¶
type TestSuiteRunner struct { TestSuite *TestSuite Delegate TestRunnerDelegate }
TestSuiteRunner runs given test suite config with the help of delegate supplied to it
func (*TestSuiteRunner) RunTests ¶
func (runner *TestSuiteRunner) RunTests()
RunTests runs the tests from the test suite