testdsl

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 4 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(resp interactor.Response, err error)

Checker asserts the given results.

type GivenFn

type GivenFn func() interactor.UseCaseRunner

GivenFn is a test init function.

func Given

func Given(useCaseRunner interactor.UseCaseRunnerFn) GivenFn

Given prepares the given use case runner for testing.

type InteractorTester

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

InteractorTester defines a Test Suite.

func Test

func Test(tb testing.TB) InteractorTester

Test runs the test.

Example:

want := &TestResponse{result: 123}
useCaseRunner := &ConcreteUseCase{res: want.result}
adaptedUseCaseRunner := interactor.MustAdapt(useCaseRunner.Run)

Test(t)(
	Given(adaptedUseCaseRunner.Run),
	When(context.Background(), TestRequest{123}, &TestResponse{}),
	Then(want))

type ThenFn

type ThenFn func(t testing.TB) Checker

ThenFn prepares the Checker.

func Then

func Then(want interactor.Response) ThenFn

Then asserts that the expected response is returned.

func ThenFailWith

func ThenFailWith(want error) ThenFn

ThenFailWith asserts that the expected error occurred.

type WhenFn

type WhenFn func(useCaseRunner interactor.UseCaseRunner) (interactor.Response, error)

WhenFn is a use case runner function.

func When

When runs the use case.

Jump to

Keyboard shortcuts

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