Documentation ¶
Index ¶
- type TransactionChecker
- func SetAfterHooks(c *gc.C, runner txn.Runner, fs ...func()) TransactionChecker
- func SetBeforeHooks(c *gc.C, runner txn.Runner, fs ...func()) TransactionChecker
- func SetFailIfTransaction(c *gc.C, runner txn.Runner) TransactionChecker
- func SetRetryHooks(c *gc.C, runner txn.Runner, block, check func()) TransactionChecker
- func SetTestHooks(c *gc.C, runner txn.Runner, hooks ...txn.TestHook) TransactionChecker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TransactionChecker ¶
type TransactionChecker func()
TransactionChecker values are returned from the various Set*Hooks calls, and should be run after the code under test has been executed to check that the expected number of transactions were run.
func SetAfterHooks ¶
func SetAfterHooks(c *gc.C, runner txn.Runner, fs ...func()) TransactionChecker
SetAfterHooks uses Settxn.TestHooks to queue N functions to be run immediately after the next N transactions. The first function is executed after the first transaction, the second function after the second transaction and so on.
func SetBeforeHooks ¶
func SetBeforeHooks(c *gc.C, runner txn.Runner, fs ...func()) TransactionChecker
SetBeforeHooks uses Settxn.TestHooks to queue N functions to be run immediately before the next N transactions. The first function is executed before the first transaction, the second function before the second transaction and so on. Nil values are accepted, and useful, in that they can be used to ensure that a transaction is run at the expected time, without having to make any changes or assert any state.
func SetFailIfTransaction ¶
func SetFailIfTransaction(c *gc.C, runner txn.Runner) TransactionChecker
SetFailIfTransaction will set a transaction hook that marks the test as an error if there is a transaction run. This is used if you know a given set of operations should *not* trigger database updates.
func SetRetryHooks ¶
func SetRetryHooks(c *gc.C, runner txn.Runner, block, check func()) TransactionChecker
SetRetryHooks uses txn.TestHooks to inject a block function designed to disrupt a transaction built against recent state, and a check function designed to verify that the replacement transaction against the new state has been applied as expected.
func SetTestHooks ¶
SetTestHooks queues up hooks to be applied to the next transactions, and returns a function that asserts all hooks have been run (and removes any that have not). Each hook function can freely execute its own transactions without causing other hooks to be triggered. It returns a function that asserts that all hooks have been run, and removes any that have not. It is an error to set transaction hooks when any are already queued; and setting transaction hooks renders the *State goroutine- unsafe.
func (TransactionChecker) Check ¶
func (c TransactionChecker) Check()