suite

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeBodyProtobuf added in v0.16.0

func EncodeBodyProtobuf(body ProtobufEncodable) any

func ReadBodyFile added in v0.16.0

func ReadBodyFile(bodyFile string) any

func Run

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

func WithConfigDebug added in v0.26.2

func WithConfigDebug(s *suiteOptions)

func WithStreamConsumerRetryDisabled added in v0.26.2

func WithStreamConsumerRetryDisabled(s *suiteOptions)

Types

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
	Version int
	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
	Version       int
	Input         interface{}
	Assert        DdbSubscriberAssertion
}

type HttpserverTestCase added in v0.15.0

type HttpserverTestCase struct {
	Method  string
	Url     string
	Headers map[string]string
	// Body will be used as the request body. Supported request body data types is `string`,
	// `[]byte`, `struct`, `map`, `slice` and `io.Reader`. Body value can be pointer or non-pointer.
	// Automatic marshalling for JSON and XML content type, if it is `struct`, `map`, or `slice`.
	//
	// If you call EncodeBodyProtobuf on your body before assigning it to this field, it will instead be
	// encoded using protobuf.
	//
	// To send the contents of a file, you can use ReadBodyFile and assign the result to this field. The
	// test suite will read the file contents and send it as your request.
	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
	// AssertResultFile can be used to read the expected response body from a file, which will be used to check equality
	// with the actual response body. If the file name extension is .json, the equality check is done via assert.JSONEq.
	AssertResultFile string
}

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{}
	Version int
	Assert  KvStoreSubscriberAssertion
}

type Option

type Option func(s *suiteOptions)

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]any) 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 WithFixtureSetFactories added in v0.24.0

func WithFixtureSetFactories(factories ...fixtures.FixtureSetsFactory) Option

func WithHttpServerShares added in v0.15.0

func WithHttpServerShares() Option

func WithIpReadFromMemory

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

func WithLogLevel

func WithLogLevel(level string) Option

func WithLogRecording added in v0.18.1

func WithLogRecording() Option

func WithModule

func WithModule(name string, essentialModule 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 ProtobufEncodable added in v0.16.0

type ProtobufEncodable interface {
	ToMessage() (proto.Message, error)
}

type StreamTestCase

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

type StreamTestCaseInput

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

type StreamTestCaseOutput

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

type SubscriberTestCase

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

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) FailIfError added in v0.20.0

func (s *Suite) FailIfError(err error, msgAndArgs ...interface{})

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() httpserver.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