testdsl

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker func(report interface{}, err error)

Checker asserts the given results.

type GivenFn

type GivenFn func() (queryer.QueryRunner, error)

GivenFn is a test init function.

func Given

func Given(queryType string, concreteQueryRunner interface{}) GivenFn

Given prepares the given query runner for testing.

type QueryerTester

type QueryerTester func(given GivenFn, when WhenFn, then ThenFn)

QueryerTester defines a query runner tester.

func Test

func Test(t testing.TB) QueryerTester

Test runs the test.

Example:

want := &mock.TestReport{Value: 123}
queryRunner := &mock.ConcreteQueryerStub{Rep: 123}

Test(t)(
	Given("TestQuery", queryRunner.Run),
	When(context.Background(), mock.TestQuery{}, &mock.TestReport{}),
	Then(want),
)

type ThenFn

type ThenFn func(t testing.TB) Checker

ThenFn prepares the Checker.

func Then

func Then(want interface{}) ThenFn

Then asserts that the expected events are applied.

func ThenFailWith

func ThenFailWith(want error) ThenFn

ThenFailWith asserts that the expected error occurred.

type WhenFn

type WhenFn func(queryRunner queryer.QueryRunner, err error) (interface{}, error)

WhenFn is a command handler function.

func When

func When(ctx context.Context, q interface{}, r interface{}) WhenFn

When prepares the command handler for the given command.

Jump to

Keyboard shortcuts

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