apocheck

package module
Version: v0.0.0-...-12130da Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 27 Imported by: 16

README

apocheck

Apocheck is a library that allows to create integration tests easily.

It can be used to create a test cli in a second and let you focus on writing simple tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t TestInfo, message string, actual interface{}, f func(interface{}, ...interface{}) string, expected ...interface{})

Assert can use goconvey function to perform an assertion.

func AssertNoPush

func AssertNoPush(
	ctx context.Context,
	t TestInfo,
	m manipulate.Manipulator,
	identity elemental.Identity,
	eventType elemental.EventType,
	options ...AssertPushOption,
) func() func() error

AssertNoPush asserts a push is not received.

func AssertPush

func AssertPush(
	ctx context.Context,
	t TestInfo,
	m manipulate.Manipulator,
	identity elemental.Identity,
	eventType elemental.EventType,
	options ...AssertPushOption,
) func() func() error

AssertPush asserts a push is correctly received.

func AssertPushOptionAdditionalFilter

func AssertPushOptionAdditionalFilter(filter func(event *elemental.Event) bool) func(cfg *assertPushConfig)

AssertPushOptionAdditionalFilter sets an additional filter to basic elemental.Identity and elemental.EventType matching. If it returns false, the push assertion function continues to wait.

func AssertPushOptionEventAsserter

func AssertPushOptionEventAsserter(asserter func(event *elemental.Event, identifiable elemental.Identifiable) error) func(cfg *assertPushConfig)

AssertPushOptionEventAsserter sets the function to run to validate the event and its content after the filter matches.

func AssertPushOptionNegativeTimeout

func AssertPushOptionNegativeTimeout(timeout time.Duration) func(cfg *assertPushConfig)

AssertPushOptionNegativeTimeout sets the time to wait for a push assertion that should not find a push. Default is 3s.

func AssertPushOptionPositiveTimeout

func AssertPushOptionPositiveTimeout(timeout time.Duration) func(cfg *assertPushConfig)

AssertPushOptionPositiveTimeout sets the time to wait for a push assertion that should find a push.Default is 10s.

func AssertPushOptionSubscriberOptions

func AssertPushOptionSubscriberOptions(options ...maniphttp.SubscriberOption) func(cfg *assertPushConfig)

AssertPushOptionSubscriberOptions passes additional maniphttp.SuscriberOptions to the underlying maniphttp.Subscriber.

func CreateNamespace

CreateNamespace creates the namespace with the given name in the given namespace. It returns the created namespace, a manipulate.Context pointing to the namespace and an eventual error.

func ListenForPushEvent

func ListenForPushEvent(ctx context.Context, m manipulate.Manipulator, verifier func(*elemental.Event) bool, evtCh chan *elemental.Event, options ...maniphttp.SubscriberOption) error

ListenForPushEvent listen for a event

func NewCommand

func NewCommand(
	name string,
	description string,
	version string,
) *cobra.Command

NewCommand generates a new CLI for regolith

func RegisterTest

func RegisterTest(t Test)

RegisterTest register a test in the main suite.

func Step

func Step(t TestInfo, name string, step func() error)

Step runs a particular step.

Types

type AssertPushOption

type AssertPushOption func(*assertPushConfig)

An AssertPushOption represents options to push assertion functions.

type Cleanup

type Cleanup func() error

Cleanup function is a type function.

func CreateAccount

CreateAccount creates the given gaia.Account and returns a manipulator for this account.

func CreateNamespaces

func CreateNamespaces(ctx context.Context, m manipulate.Manipulator, rootNamespace string, nss string) (c Cleanup, err error)

CreateNamespaces creates the desired namespace line.

func CreateTestAccount

CreateTestAccount creates an account using the given TestInfo and returns an authenticated manipulator.

func CreateTestNamespace

func CreateTestNamespace(ctx context.Context, m manipulate.Manipulator, t TestInfo) (string, Cleanup, error)

CreateTestNamespace a namespace using the given TestInfo.

type SetupFunction

type SetupFunction func(context.Context, TestInfo) (interface{}, TearDownFunction, error)

SetupFunction is the type of function that can be run a a test setup. The returned data will be available to the main test function using TestInfo.SetupInfo() function. The returned function will be run at the end of the test.

If SetupFunction returns an error, the entire suite of test is stopped.

type SetupSuiteFunction

type SetupSuiteFunction func(context.Context, SuiteInfo) (interface{}, TearDownFunction, error)

SetupSuiteFunction is the type of function that can be run from a suite setup. The returned data will be available to the main test function using TestInfo.SuiteSetupInfo() function. The returned function will be run at the end of the suite.

If SetupSuiteFunction returns an error, the entire suite of test is stopped.

type Suite

type Suite struct {
	Name        string
	Description string
	Setup       SetupSuiteFunction
}

Suite is a collection of tests

type SuiteInfo

type SuiteInfo interface {
	RegisterTest(t Test)
	// SetupInfo provides the user data
	SetupInfo() interface{}
	// Write performs a write
	Write(p []byte) (n int, err error)
}

SuiteInfo is the interface for the test writer

func RegisterSuite

func RegisterSuite(s Suite) SuiteInfo

RegisterSuite registers a test suite.

type TearDownFunction

type TearDownFunction func()

A TearDownFunction is the type of function returned by a SetupFunction.

type Test

type Test struct {
	Name        string
	Description string
	Author      string
	Tags        []string
	Setup       SetupFunction
	Function    TestFunction
	SuiteName   string
	// contains filtered or unexported fields
}

A Test represents an actual test.

func (Test) MatchTags

func (t Test) MatchTags(tags []string, matchAll bool) bool

MatchTags matches all tags if --match-all is set otherwise matches any tag

func (Test) String

func (t Test) String() string

type TestFunction

type TestFunction func(context.Context, TestInfo) error

A TestFunction is the type of a function that is run by a Test.

type TestInfo

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

A TestInfo contains various information about a test.

func (TestInfo) Account

func (t TestInfo) Account(password string) *gaia.Account

Account returns a gaia Account object that can be used for the test.

func (TestInfo) AccountName

func (t TestInfo) AccountName() string

AccountName returns a unique account name that can be used by this test.

func (TestInfo) AccountNamespace

func (t TestInfo) AccountNamespace() string

AccountNamespace returns the account namespace that can be used by this test.

func (TestInfo) Iteration

func (t TestInfo) Iteration() int

Iteration returns the test iteration number.

func (TestInfo) PrivateAPI

func (t TestInfo) PrivateAPI() string

PrivateAPI returns the private API endpoint.

func (TestInfo) PrivateTLSConfig

func (t TestInfo) PrivateTLSConfig() *tls.Config

PrivateTLSConfig returns the public TLS config.

func (TestInfo) PublicAPI

func (t TestInfo) PublicAPI() string

PublicAPI returns the public API endpoint.

func (TestInfo) PublicManipulator

func (t TestInfo) PublicManipulator() manipulate.Manipulator

PublicManipulator returns the public manipulator if any.

func (TestInfo) PublicTLSConfig

func (t TestInfo) PublicTLSConfig() *tls.Config

PublicTLSConfig returns the public TLS config.

func (TestInfo) RootManipulator

func (t TestInfo) RootManipulator() manipulate.Manipulator

RootManipulator returns the root manipulator if any.

func (TestInfo) SetupInfo

func (t TestInfo) SetupInfo() interface{}

SetupInfo returns the eventual object stored by the Setup function.

func (TestInfo) SuiteSetupInfo

func (t TestInfo) SuiteSetupInfo() interface{}

SuiteSetupInfo returns the eventual object stored by the Suite Setup function.

func (TestInfo) TestID

func (t TestInfo) TestID() string

TestID returns the test ID

func (TestInfo) TestNamespace

func (t TestInfo) TestNamespace(iteration int) string

TestNamespace returns a unique namespace that can be used by this test.

func (TestInfo) TimeSinceLastStep

func (t TestInfo) TimeSinceLastStep() string

TimeSinceLastStep provides the time since last step or assertion

func (TestInfo) Timeout

func (t TestInfo) Timeout() time.Duration

Timeout provides the duration before the test timeout.

func (TestInfo) Write

func (t TestInfo) Write(p []byte) (n int, err error)

Write performs a write

func (TestInfo) WriteHeader

func (t TestInfo) WriteHeader(p []byte) (n int, err error)

WriteHeader performs a write at the header

Jump to

Keyboard shortcuts

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