testing

package
v0.0.0-...-ee03468 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2014 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

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

func SetTestHooks(c *gc.C, runner txn.Runner, hooks ...txn.TestHook) TransactionChecker

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()

Jump to

Keyboard shortcuts

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