testenv

package
v0.135.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ISO8601 = "2006-01-02T15:04:05-07:00"

Variables

View Source
var BasicConfig = eventstore.Config{
	VATRates: []eventio.VATRate{
		{
			Code:      "Standard",
			Rate:      0.2,
			ValidFrom: "epoch",
		},
	},
	CurrencyRates: []eventio.CurrencyRate{
		{
			Code:      "GBP",
			Rate:      1,
			ValidFrom: "epoch",
		},
	},
	PricingPlans: []eventio.PricingPlan{},
}

Functions

func DropAllDatabases added in v0.132.0

func DropAllDatabases() error

func Time

func Time(s string) time.Time

T parses an ISO8601 or RFC3339 or YYYY-MM-DD formated string and returns a time.Time or panics

Types

type EventInfo added in v0.43.0

type EventInfo struct {
	CreatedAt string
	Delta     string
	State     string
	Updates   string
}

type Row

type Row map[string]interface{}

func (Row) String

func (row Row) String() string

type Rows

type Rows []Row

func (Rows) String

func (rows Rows) String() string

type TempDB

type TempDB struct {
	MasterConnectionString string
	TempConnectionString   string
	Schema                 eventio.EventStore
	Conn                   *sql.DB
	// contains filtered or unexported fields
}

func MustOpen

func MustOpen(cfg eventstore.Config) *TempDB

MustOpen is a panicy version of Open

func New

func New() (*TempDB, error)

func Open

func Open(cfg eventstore.Config) (*TempDB, error)

func OpenWithContext added in v0.132.0

func OpenWithContext(cfg eventstore.Config, ctx context.Context) (*TempDB, error)

Opens creates a new database named test_<uuid> and runs Init() with the given config

func (*TempDB) Cleanup added in v0.132.0

func (db *TempDB) Cleanup() error

func (*TempDB) Close

func (db *TempDB) Close() error

Close closes the database connection. This needs to gracefully handle the database, and the connection being 'nil' - some specs deliberately cause this state

func (*TempDB) Get

func (db *TempDB) Get(q string, args ...interface{}) interface{}

Perform a query that returns a single row single column and return whatever it is This is useful for testing

func (*TempDB) Insert

func (db *TempDB) Insert(tableName string, rows ...Row) error

Insert is way of inserting Row objects (generic json representations of data) into the database it makes it a bit easier to read the intention of the insert in tests than raw sql

func (*TempDB) Query

func (db *TempDB) Query(q string, args ...interface{}) Rows

Perform a query and return the result as thinly typed Rows

type TestScenario added in v0.43.0

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

func NewTestScenario added in v0.43.0

func NewTestScenario(baseTimeStr string) *TestScenario

func (*TestScenario) AddComponent added in v0.43.0

func (t *TestScenario) AddComponent(planName, validFrom, componentName, formula, currency, vat string)

func (*TestScenario) AddComputePlan added in v0.43.0

func (t *TestScenario) AddComputePlan()

func (*TestScenario) AppLifeCycle added in v0.43.0

func (t *TestScenario) AppLifeCycle(
	orgName string,
	spaceName string,
	appName string,
	eventsInfo ...EventInfo,
)

func (*TestScenario) DeltaTime added in v0.43.0

func (t *TestScenario) DeltaTime(ds string) time.Time

func (*TestScenario) DeltaTimeJSON added in v0.43.0

func (t *TestScenario) DeltaTimeJSON(ds string) string

func (*TestScenario) DeltaTimeRFC3339 added in v0.43.0

func (t *TestScenario) DeltaTimeRFC3339(ds string) string

func (*TestScenario) FlushAppEvents added in v0.43.0

func (t *TestScenario) FlushAppEvents(db *TempDB) error

func (*TestScenario) FlushEntities added in v0.53.0

func (t *TestScenario) FlushEntities(db *TempDB, cfg eventstore.Config) error

func (*TestScenario) GetAppEventGUIDs added in v0.43.0

func (t *TestScenario) GetAppEventGUIDs(orgName, spaceName, appName string) []string

func (*TestScenario) GetAppGUID added in v0.43.0

func (t *TestScenario) GetAppGUID(orgName, spaceName, appName string) string

func (*TestScenario) GetOrgGUID added in v0.43.0

func (t *TestScenario) GetOrgGUID(orgName string) string

func (*TestScenario) GetPlan added in v0.43.0

func (t *TestScenario) GetPlan(planName, validFrom string) *eventio.PricingPlan

func (*TestScenario) GetPlanGUID added in v0.43.0

func (t *TestScenario) GetPlanGUID(planName, validFrom string) string

func (*TestScenario) GetSpaceGUID added in v0.43.0

func (t *TestScenario) GetSpaceGUID(orgName, spaceName string) string

func (*TestScenario) Open added in v0.43.0

func (t *TestScenario) Open(cfg eventstore.Config) (*TempDB, error)

func (*TestScenario) OpenInto added in v0.132.0

func (t *TestScenario) OpenInto(db *TempDB, cfg eventstore.Config) error

func (*TestScenario) OpenWithContext added in v0.132.0

func (t *TestScenario) OpenWithContext(cfg eventstore.Config, ctx context.Context) (*TempDB, error)

Jump to

Keyboard shortcuts

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