Documentation ¶
Overview ¶
Package mlabtest is used to run unit tests that set up a whole lab
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSourceDir ¶
GetSourceDir return the path in the source where the type is defined.
Note: We need to have the sources (in the correct GOPATH) for this to work
Useful for loading test resources from the source directory of a library in test that use that library
func NeedForwarding ¶
func NeedForwarding() bool
NeedForwarding return true if the labs need to be accessed at 127.0.0.1 with the mapped ports otherwise they can be accessed at their own address with the original port
func NewLineLogger ¶
func NewLineLogger(f LogFunc) io.WriteCloser
NewLineLogger allow to log lines of output produced by MLab containers It create an io.WriteCloser that parses the output into line and send them to the specified function.
Types ¶
type MLab ¶
type MLab struct { // if logger is set it would be called to log "internal" MLab events Logger func(string) // if Stdin is not nill it is connected to the mlab // otherwise it is connected to the null device. // Must be set before calling Start Stdin io.Reader // id Stdout and/or Stderr are not nill they are connected to the mlab // (stdout is not connected directly) Stdout io.Writer Stderr io.Writer // contains filtered or unexported fields }
MLab represent a running minutelab
After creating the lab object, and possibly setting other paramters, the lab is started with the Start method.
The lab should be closed with the Close method (even if it was only created or if start return an error) The lab should be built such that when it is ready it will detach
func New ¶
New create (but does not start) a new mlab with the specified arguments The lab can be optionally associated with a testing framework object (like *testing.T), if it does it behave in a way more suitable for unit testing:
- Both New and Start won't return errors, instead the would abort the test using Fatal, so testing code does not need to explicitly check for errors
- It will send logs about lab setup through the testing log function
func NewStart ¶
NewStart create a new lab and start it immediatly if tb is not nil testing code can assume that the function succeed and not test for errors
func (*MLab) GetAddressPort ¶
GetAddressPort return the address and port to be used to access the specified internal port
Directories ¶
Path | Synopsis |
---|---|
Package sqitchdb allow "unit testing" of (postgres) database whose schema is controlled by sqitch Calling New will start a container running postgres with the latest schema/data loaded.
|
Package sqitchdb allow "unit testing" of (postgres) database whose schema is controlled by sqitch Calling New will start a container running postgres with the latest schema/data loaded. |