test

package
v0.0.0-...-b8c8fdf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SingleRecord = store.Record{
		Version: 1,
		Data:    json.RawMessage(`{ "type": "single", "field": "value" }`),
	}

	OneRecord = store.Record{
		Version: 1,
		Data:    json.RawMessage(`{ "type": "one", "field": "value1" }`),
	}
	TwoRecord = store.Record{
		Version: 2,
		Data:    json.RawMessage(`{ "type": "two", "field": "value2" }`),
	}
	ThreeRecord = store.Record{
		Version: 3,
		Data:    json.RawMessage(`{ "type": "three", "field": "value3" }`),
	}
	FourRecord = store.Record{
		Version: 4,
		Data:    json.RawMessage(`{ "type": "four", "field": "value4" }`),
	}
	FiveRecord = store.Record{
		Version: 5,
		Data:    json.RawMessage(`{ "type": "five", "field": "value5" }`),
	}
	SixRecord = store.Record{
		Version: 6,
		Data:    json.RawMessage(`{ "type": "six", "field": "value6" }`),
	}
)

Functions

func AssertJSONDataMatch

func AssertJSONDataMatch(t *testing.T, expected, actual store.Record)

func AssertStreamContents

func AssertStreamContents(t *testing.T, fixture *Fixture, stream store.Stream)

func AssertStreamLength

func AssertStreamLength(t *testing.T, stream store.Stream, length int)

func AssertVersionsMatch

func AssertVersionsMatch(t *testing.T, expected, actual store.Record)

func InsertRecord

func InsertRecord(t *testing.T, dataSource string, aggregate store.Aggregate, params sqlc.AppendEventParams)

func InsertRecords

func InsertRecords(t *testing.T, dataSource string, aggregate store.Aggregate, records ...store.Record)

func LoadStream

func LoadStream(t *testing.T, s store.Store, aggregateID store.ID, from int32, to int32) store.Stream

func NewPostgresWaitStrategy

func NewPostgresWaitStrategy() *wait.LogStrategy

NewPostgresWaitStrategy wait strategy for use when testing against Postgres container as it restarts on startup.

Waits until the log message "database system is ready to accept connections" is logged twice or timeout threshold of 60 seconds is exceeded.

Types

type AStub

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

func (AStub) ID

func (a AStub) ID() store.ID

type Database

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

func NewDatabase

func NewDatabase(t *testing.T) *Database

func (*Database) ConnectionString

func (tdb *Database) ConnectionString(t *testing.T) string

func (*Database) PasswordConfig

func (tdb *Database) PasswordConfig(t *testing.T) pgstore.PasswordConfig

func (*Database) Port

func (tdb *Database) Port(t *testing.T) int

type Fixture

type Fixture struct {
	Aggregate      store.Aggregate
	Records        []store.Record
	FromVersion    int32
	ToVersion      int32
	ExpectedLength int
	// contains filtered or unexported fields
}

func NewFixture

func NewFixture() *Fixture

func (*Fixture) Build

func (f *Fixture) Build() *Fixture

func (*Fixture) For

func (f *Fixture) For(aggregateID store.ID) *Fixture

func (*Fixture) From

func (f *Fixture) From(from int32) *Fixture

func (*Fixture) OfLength

func (f *Fixture) OfLength(expectedLength int) *Fixture

func (*Fixture) To

func (f *Fixture) To(to int32) *Fixture

func (*Fixture) With

func (f *Fixture) With(records ...store.Record) *Fixture

Jump to

Keyboard shortcuts

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