Documentation ¶
Overview ¶
Package test contains simple test helpers that should not have any dependencies on millennium's packages. think constants, custom matchers, generic helpers etc.
Index ¶
- func AiBlocksCoreDatabase(t *testing.T) *sqlx.DB
- func AiBlocksCoreDatabaseURL() string
- func Context() context.Context
- func Database(t *testing.T) *sqlx.DB
- func DatabaseURL() string
- func OverrideLogger(l *log.Entry)
- func RequestHelperRaw(r *http.Request)
- func RequestHelperStreaming(r *http.Request)
- func ResetMillenniumDB(t *testing.T, db *sqlx.DB)
- func RestoreLogger()
- type Assertions
- type RequestHelper
- type StaticMockServer
- type T
- func (t *T) CoreSession() *db.Session
- func (t *T) Finish()
- func (t *T) MillenniumSession() *db.Session
- func (t *T) Scenario(name string) *T
- func (t *T) ScenarioWithoutMillennium(name string) *T
- func (t *T) UnmarshalExtras(r io.Reader) map[string]string
- func (t *T) UnmarshalNext(r io.Reader) string
- func (t *T) UnmarshalPage(r io.Reader, dest interface{}) hal.Links
- func (t *T) UpdateLedgerState()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AiBlocksCoreDatabase ¶
AiBlocksCoreDatabase returns a connection to the aiblocks core test database
DEPRECATED: use `AiBlocksCore()` from test/db package
func AiBlocksCoreDatabaseURL ¶
func AiBlocksCoreDatabaseURL() string
AiBlocksCoreDatabaseURL returns the database connection the url any test use when connecting to the aiblocks-core database
DEPRECATED: use `AiBlocksCoreURL()` from test/db package
func Context ¶
Context provides a context suitable for testing in tests that do not create a full App instance (in which case your tests should be using the app's context). This context has a logger bound to it suitable for testing.
func Database ¶
Database returns a connection to the millennium test database
DEPRECATED: use `Millennium()` from test/db package
func DatabaseURL ¶
func DatabaseURL() string
DatabaseURL returns the database connection the url any test use when connecting to the history/millennium database
DEPRECATED: use `MillenniumURL()` from test/db package
func OverrideLogger ¶
OverrideLogger sets the default logger used by millennium to `l`. This is used by the testing system so that we can collect output from logs during test runs. Panics if the logger is already overridden.
func RequestHelperRaw ¶
func RequestHelperStreaming ¶
func ResetMillenniumDB ¶
ResetMillenniumDB sets up a new millennium database with empty tables
func RestoreLogger ¶
func RestoreLogger()
RestoreLogger restores the default millennium logger after it is overridden using a call to `OverrideLogger`. Panics if the default logger is not presently overridden.
Types ¶
type Assertions ¶
type Assertions struct {
*assert.Assertions
}
Assertions provides an assertions helper. Custom assertions for this package can be defined as methods on this struct. foo
func (*Assertions) Problem ¶
Problem asserts that `body` is a serialized problem equal to `expected`, using Type and Status to compare for equality.
func (*Assertions) ProblemType ¶
func (a *Assertions) ProblemType(body *bytes.Buffer, typ string) bool
ProblemType asserts that the provided `body` is a JSON serialized problem whose type is `typ`
type RequestHelper ¶
type RequestHelper interface { Get(string, ...func(*http.Request)) *httptest.ResponseRecorder Post(string, url.Values, ...func(*http.Request)) *httptest.ResponseRecorder }
func NewRequestHelper ¶
func NewRequestHelper(router *chi.Mux) RequestHelper
type StaticMockServer ¶
StaticMockServer is a test helper that records it's last request
func NewStaticMockServer ¶
func NewStaticMockServer(response string) *StaticMockServer
NewStaticMockServer creates a new mock server that always responds with `response`
type T ¶
type T struct { T *testing.T Assert *assert.Assertions Require *require.Assertions Ctx context.Context MillenniumDB *sqlx.DB CoreDB *sqlx.DB Logger *log.Entry LogMetrics *logmetrics.Metrics LogBuffer *bytes.Buffer }
T provides a common set of functionality for each test in millennium
func (*T) CoreSession ¶
CoreSession returns a db.Session instance pointing at the aiblocks core test database
func (*T) Finish ¶
func (t *T) Finish()
Finish finishes the test, logging any accumulated millennium logs to the logs output
func (*T) MillenniumSession ¶
MillenniumSession returns a db.Session instance pointing at the millennium test database
func (*T) ScenarioWithoutMillennium ¶
ScenarioWithoutMillennium loads the named sql scenario into the database
func (*T) UnmarshalExtras ¶
UnmarshalExtras extracts and returns extras content
func (*T) UnmarshalNext ¶
UnmarshalNext extracts and returns the next link
func (*T) UnmarshalPage ¶
UnmarshalPage populates dest with the records contained in the json-encoded page in r
func (*T) UpdateLedgerState ¶
func (t *T) UpdateLedgerState()
UpdateLedgerState updates the cached ledger state (or panicing on failure).
Directories ¶
Path | Synopsis |
---|---|
Package db provides helpers to connect to test databases.
|
Package db provides helpers to connect to test databases. |
Common infrastructure for testing Trades
|
Common infrastructure for testing Trades |
Package transactions offers common infrastructure for testing Transactions
|
Package transactions offers common infrastructure for testing Transactions |