onepiecetesting

package
v0.0.0-...-5ebfc8f Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTestingFile

func RunTestingFile[State any, Command any, Event any](
	t *testing.T,
	fileName string,
	decider *onepiece.Decider[State, Command, Event],
	unmarshalCommand UnmarshalMessage[Command],
	unmarshalEvent UnmarshalMessage[Event],
)

Types

type Case

type Case struct {
	Given     []Message `json:"given" yaml:"given,omitempty"`
	When      Message   `json:"when" yaml:"when"`
	Then      []Message `json:"then" yaml:"then,omitempty"`
	Exception *Message  `json:"Exception,omitempty" yaml:"exception,omitempty"`
}

type Message

type Message struct {
	Type    string    `json:"type"`
	Payload yaml.Node `json:"payload"`
}

type TestCase

type TestCase[State any, Command any, Event any] struct {
	// contains filtered or unexported fields
}

func NewTestCase

func NewTestCase[State any, Command any, Event any](t *testing.T, decider *onepiece.Decider[State, Command, Event]) *TestCase[State, Command, Event]

func (*TestCase[State, Command, Event]) Assert

func (tc *TestCase[State, Command, Event]) Assert()

func (*TestCase[State, Command, Event]) Catch

func (tc *TestCase[State, Command, Event]) Catch(err error) *TestCase[State, Command, Event]

func (*TestCase[State, Command, Event]) Given

func (tc *TestCase[State, Command, Event]) Given(events ...Event) *TestCase[State, Command, Event]

func (*TestCase[State, Command, Event]) Then

func (tc *TestCase[State, Command, Event]) Then(event ...Event) *TestCase[State, Command, Event]

func (*TestCase[State, Command, Event]) When

func (tc *TestCase[State, Command, Event]) When(command Command) *TestCase[State, Command, Event]

type TestingFile

type TestingFile struct {
	UseCases []UseCase `json:"useCases" yaml:"useCases"`
}

func NewTestingFile

func NewTestingFile(t *testing.T, fileName string) *TestingFile

type UnmarshalMessage

type UnmarshalMessage[Message any] func(eventType string, payload yaml.Node) (Message, error)

type UseCase

type UseCase struct {
	Description string `json:"description" yaml:"description"`
	Case        Case   `json:"case" yaml:"case"`
}

Jump to

Keyboard shortcuts

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