suite

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, suite TestingSuite, extraOptions ...Option)

Types

type ApiServerTestCase

type ApiServerTestCase struct {
	Method  string
	Url     string
	Headers map[string]string
	Body    interface{}
	// ExpectedStatusCode describes the status code the last response is required to have.
	ExpectedStatusCode int
	// ExpectedRedirectsToFollow describes the number of redirects we want to follow. It is an error if less redirects
	// are performed. More redirects result in the last redirect being returned as the response instead (e.g., if it is
	// to some external site or with a protocol different from HTTP(S) like intent://) and do not result in an error.
	ExpectedRedirectsToFollow int
	// ExpectedResult defines the *type* the final response should be parsed into. You can then access the unmarshalled
	// response in response.Result().
	ExpectedResult interface{}
	// ExpectedErr is compared with the error returned by the HTTP request. Only the error messages have to match.
	ExpectedErr error
	// Assert allows you to provide an assertion function that can be passed to validate certain post conditions (like
	// messages being written to the correct queues).
	// It also allows to check that the response carries the correct response body, redirects to the correct
	//	// location, or has the correct headers set. You don't need to validate the response status here, this is already
	//	// performed automatically.
	Assert func(response *resty.Response) error
}

type AppUnderTest

type AppUnderTest interface {
	Stop()
	WaitDone()
}

type DbSubscriberAssertion

type DbSubscriberAssertion func(t *testing.T, fetcher *DbSubscriberFetcher)

type DbSubscriberFetcher

type DbSubscriberFetcher struct {
	// contains filtered or unexported fields
}

func (DbSubscriberFetcher) ByPrimaryKey

func (f DbSubscriberFetcher) ByPrimaryKey(key interface{}, model interface{})

type DbSubscriberTestCase

type DbSubscriberTestCase struct {
	Name    string
	ModelId string
	Input   interface{}
	Assert  DbSubscriberAssertion
}

type DdbSubscriberAssertion

type DdbSubscriberAssertion func(t *testing.T, fetcher *DdbSubscriberFetcher)

type DdbSubscriberFetcher

type DdbSubscriberFetcher struct {
	// contains filtered or unexported fields
}

func (DdbSubscriberFetcher) ByHash

func (f DdbSubscriberFetcher) ByHash(hash interface{}, model interface{})

func (DdbSubscriberFetcher) ByHashAndRange

func (f DdbSubscriberFetcher) ByHashAndRange(hash interface{}, rangeValue interface{}, model interface{})

type DdbSubscriberTestCase

type DdbSubscriberTestCase struct {
	Name          string
	SourceModelId string
	TargetModelId string
	Input         interface{}
	Assert        DdbSubscriberAssertion
}

type KvStoreSubscriberAssertion

type KvStoreSubscriberAssertion func(t *testing.T, fetcher *KvstoreSubscriberFetcher)

type KvstoreSubscriberFetcher

type KvstoreSubscriberFetcher struct {
	// contains filtered or unexported fields
}

func (KvstoreSubscriberFetcher) Get

func (f KvstoreSubscriberFetcher) Get(key interface{}, model mdlsub.Model)

type KvstoreSubscriberTestCase

type KvstoreSubscriberTestCase struct {
	Name    string
	ModelId string
	Input   interface{}
	Assert  KvStoreSubscriberAssertion
}

type Option

type Option func(s *suiteOptions)

func WithApiServerShares

func WithApiServerShares() Option

func WithClockProvider

func WithClockProvider(clk clock.Clock) Option

func WithClockProviderAt

func WithClockProviderAt(datetime string) Option

func WithComponent

func WithComponent(settings env.ComponentBaseSettingsAware) Option

func WithConfigFile

func WithConfigFile(file string) Option

func WithConfigMap

func WithConfigMap(settings map[string]interface{}) Option

func WithConsumer

func WithConsumer(callback stream.ConsumerCallbackFactory) Option

func WithContainerExpireAfter

func WithContainerExpireAfter(expireAfter time.Duration) Option

func WithDbRepoChangeHistory

func WithDbRepoChangeHistory() Option

func WithEnvSetup

func WithEnvSetup(setups ...func() error) Option

func WithFixtureBuilderFactories

func WithFixtureBuilderFactories(factories ...fixtures.FixtureBuilderFactory) Option

func WithIpReadFromMemory

func WithIpReadFromMemory(name string, records map[string]ipread.MemoryRecord) Option

func WithLogLevel

func WithLogLevel(level string) Option

func WithModule

func WithModule(name string, module kernel.ModuleFactory) Option

func WithModuleFactory

func WithModuleFactory(factory kernel.ModuleMultiFactory) Option

func WithSharedEnvironment

func WithSharedEnvironment() Option

func WithSubscribers

func WithSubscribers(transformerFactoryMap mdlsub.TransformerMapTypeVersionFactories) Option

func WithTestCaseRepeatCount

func WithTestCaseRepeatCount(repeatCount int) Option

WithTestCaseRepeatCount repeats the whole test suite the given number of times. This can be useful if a problem doesn't happen on every run (e.g., because it is timing dependent).

func WithTestCaseWhitelist

func WithTestCaseWhitelist(testCases ...string) Option

WithTestCaseWhitelist returns an option which only runs the tests contained in the given whitelist. A test not in the whitelist is skipped instead, allowing you to easily run a single test (e.g., for debugging).

func WithoutAutoDetectedComponents

func WithoutAutoDetectedComponents(components ...string) Option

type StreamTestCase

type StreamTestCase struct {
	Input  map[string][]StreamTestCaseInput
	Output map[string][]StreamTestCaseOutput
	Assert func() error
}

type StreamTestCaseInput

type StreamTestCaseInput struct {
	Attributes map[string]interface{}
	Body       interface{}
}

type StreamTestCaseOutput

type StreamTestCaseOutput struct {
	Model              interface{}
	ExpectedAttributes map[string]interface{}
	ExpectedBody       interface{}
}

type SubscriberTestCase

type SubscriberTestCase interface {
	GetName() string
	GetModelId() mdl.ModelId
	GetInput() interface{}
}

func DbTestCase

func DbTestCase(testCase DbSubscriberTestCase) (SubscriberTestCase, error)

func DdbTestCase

func DdbTestCase(testCase DdbSubscriberTestCase) (SubscriberTestCase, error)

func KvstoreTestCase

func KvstoreTestCase(testCase KvstoreSubscriberTestCase) (SubscriberTestCase, error)

type Suite

type Suite struct {
	*assert.Assertions
	// contains filtered or unexported fields
}

func (*Suite) Env

func (s *Suite) Env() *env.Environment

func (*Suite) SetEnv

func (s *Suite) SetEnv(env *env.Environment)

func (*Suite) SetT

func (s *Suite) SetT(t *testing.T)

func (*Suite) T

func (s *Suite) T() *testing.T

type TestingSuite

type TestingSuite interface {
	Env() *env.Environment
	SetEnv(environment *env.Environment)
	SetT(t *testing.T)
	T() *testing.T
	SetupSuite() []Option
}

type TestingSuiteApiDefinitionsAware

type TestingSuiteApiDefinitionsAware interface {
	SetupApiDefinitions() apiserver.Definer
}

type TestingSuiteApplicationAware

type TestingSuiteApplicationAware interface {
	SetupApplication() error
}

type TestingSuiteSetupTestAware

type TestingSuiteSetupTestAware interface {
	SetupTest() error
}

type TestingSuiteTearDownTestAware

type TestingSuiteTearDownTestAware interface {
	TearDownTest() error
}

Jump to

Keyboard shortcuts

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