testenv

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: MIT Imports: 13 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 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 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
}

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)

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

func (*TempDB) Close

func (db *TempDB) Close() error

Close drops the database

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 intension 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

Jump to

Keyboard shortcuts

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