testsuite

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package testsuite contains the standard test suite

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigIntComparer added in v0.0.2

func BigIntComparer() cmp.Option

BigIntComparer gets the big int comparer for testing.

func Eventually added in v0.0.35

func Eventually(ctx context.Context, tb testing.TB, willBeTrue func() bool)

Eventually asserts willBeTrue is true before the test context times out.

func GetFunctionName added in v0.0.52

func GetFunctionName(i interface{}) string

GetFunctionName returns the name of the function passed in. this is useful for getting the name of the test function that is running.

func MustMarshall added in v0.0.35

func MustMarshall(tb testing.TB, v any) []byte

MustMarshall is a helper method that attempts to marshall, otherwise it fails the test.

Types

type TestSuite

type TestSuite struct {
	suite.Suite
	// logDir is the directory where logs will be written for the docker containers that host the anvil nodes
	// this allows you to do tai -f /path/to/logs/*.combined.log to see all logs
	LogDir string
	// contains filtered or unexported fields
}

TestSuite defines the basic test suite. TODO: we should make sure global vars don't get mutated. Namely eth params.

func NewTestSuite

func NewTestSuite(tb testing.TB) *TestSuite

NewTestSuite creates a new test suite and performs some basic checks afterward. Every test suite in the synapse library should inherit from this suite and override where necessary.

func (*TestSuite) BeforeTest added in v0.0.31

func (s *TestSuite) BeforeTest(_, _ string)

BeforeTest performs some assertions and sets up the test.

func (*TestSuite) DeferAfterSuite

func (s *TestSuite) DeferAfterSuite(newFunc func())

DeferAfterSuite runs a function after the suite. This will run before context cancellation if you'd like to do otherwise you can from a new goroutine that watches SuiteContext() TODO: in cases of crashes this will not be done so fix this.

func (*TestSuite) DeferAfterTest

func (s *TestSuite) DeferAfterTest(newFunc func())

DeferAfterTest runs a function after the test. This will run before context cancellation if you'd like to do otherwise you can from a new goroutine that watches TestContext() TODO: in cases of crashes this will not be done so fix this.

func (*TestSuite) Eventually

func (s *TestSuite) Eventually(willBeTrue func() bool)

Eventually asserts something is eventually true. Note: this uses the suite context instead of the test context. TODO: either separate suite and test context calls or deprecte and require generic.

func (*TestSuite) GetSuiteContext

func (s *TestSuite) GetSuiteContext() context.Context

GetSuiteContext returns the context for the test suite.

func (*TestSuite) GetTestContext

func (s *TestSuite) GetTestContext() context.Context

GetTestContext gets the context object for the suite. This is an alias for GetTestContext() TODO: right now this is run as a test because of naming. this is mostly harmless.

func (*TestSuite) GetTestID

func (s *TestSuite) GetTestID() int

GetTestID gets the unique test id for the current test. uniqueness is per-suite.

func (*TestSuite) MustMarshall added in v0.0.9

func (s *TestSuite) MustMarshall(v any) []byte

MustMarshall is a helper method that attempts to marshall, otherwise it fails the test.

func (*TestSuite) SetTestTimeout added in v0.0.3

func (s *TestSuite) SetTestTimeout(timeout time.Duration)

SetTestTimeout will create a test timout override for the context. this will wrap s.testContext. TODO: consider enabling a value by default.

func (*TestSuite) SetupSuite

func (s *TestSuite) SetupSuite()

SetupSuite sets up the test suite.

func (*TestSuite) SetupTest

func (s *TestSuite) SetupTest()

SetupTest runs checks at the end of the test suite.

func (*TestSuite) TearDownSuite

func (s *TestSuite) TearDownSuite()

TearDownSuite tears down the test suite.

func (*TestSuite) TearDownTest

func (s *TestSuite) TearDownTest()

TearDownTest runs checks at the end of the test suite.

Jump to

Keyboard shortcuts

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