Documentation
¶
Index ¶
- Variables
- func Restore()
- type Action
- type Expectation
- type FileConsumer
- type LogExpectation
- type LogsConsumer
- type Negation
- func (not *Negation) Be() Expectation
- func (not *Negation) Empty()
- func (not *Negation) Equal(given interface{})
- func (not *Negation) EqualTo(given interface{})
- func (not *Negation) Equals(given interface{})
- func (not *Negation) False()
- func (not *Negation) HasLength(given int)
- func (not *Negation) HaveLength(given int)
- func (not *Negation) Is() Expectation
- func (not *Negation) Match(pattern string)
- func (not *Negation) Matches(pattern string)
- func (not *Negation) Nil()
- func (not *Negation) Not() Expectation
- func (not *Negation) Should() Expectation
- func (not *Negation) To() Expectation
- func (not *Negation) True()
- type Transformation
- type UnitTest
- func (unit *UnitTest) CaptureLogs(consumer LogsConsumer) (stdout []*LogExpectation, stderr []*LogExpectation)
- func (unit *UnitTest) Expect(actual interface{}) Expectation
- func (unit *UnitTest) ExpectExitCode(act Action) Expectation
- func (unit *UnitTest) ExpectFile(file *os.File) Expectation
- func (unit *UnitTest) ExpectOutput(consumer FileConsumer) Expectation
- type ValueExpectation
- func (e *ValueExpectation) Be() Expectation
- func (e *ValueExpectation) Empty()
- func (e *ValueExpectation) Equal(expected interface{})
- func (e *ValueExpectation) EqualTo(expected interface{})
- func (e *ValueExpectation) Equals(expected interface{})
- func (e *ValueExpectation) False()
- func (e *ValueExpectation) HasLength(expected int)
- func (e *ValueExpectation) HaveLength(expected int)
- func (e *ValueExpectation) Is() Expectation
- func (e *ValueExpectation) Match(pattern string)
- func (e *ValueExpectation) Matches(pattern string)
- func (e *ValueExpectation) Nil()
- func (e *ValueExpectation) Not() Expectation
- func (e *ValueExpectation) Should() Expectation
- func (e *ValueExpectation) To() Expectation
- func (e *ValueExpectation) True()
Constants ¶
This section is empty.
Variables ¶
var Scaffold *scaffold
Scaffold a set of functions that may be replaced for testing
Functions ¶
Types ¶
type Expectation ¶
type Expectation interface {
// Sugar
To() Expectation
Be() Expectation
Is() Expectation
Should() Expectation
// Negation
Not() Expectation
// Assertions
Nil()
True()
False()
Empty()
HasLength(expected int)
HaveLength(expected int)
Equal(expected interface{})
Equals(expected interface{})
EqualTo(expected interface{})
Match(pattern string)
Matches(pattern string)
}
Expectation represents an expectation about a value or behavior
func ExpectValue ¶
func ExpectValue(t *testing.T, actual interface{}) Expectation
ExpectValue returns a new value-based Expectation
type FileConsumer ¶
FileConsumer is a function that consumes a file
type LogExpectation ¶
type LogExpectation struct {
Time Expectation
Name Expectation
Level Expectation
Fields Expectation
Message Expectation
FullText Expectation
}
LogExpectation is a set of expectations based on parsed logs
type LogsConsumer ¶
LogsConsumer is a function that consumes two streams
type Negation ¶
type Negation struct {
*testing.T
Actual interface{}
Inverse Expectation
}
Negation is a negated expectation
func (*Negation) Empty ¶
func (not *Negation) Empty()
Empty asserts the value is an array with length != 0
func (*Negation) Equal ¶
func (not *Negation) Equal(given interface{})
Equal is equivalent to Equals()
func (*Negation) EqualTo ¶
func (not *Negation) EqualTo(given interface{})
EqualTo is equivalent to Equals()
func (*Negation) Equals ¶
func (not *Negation) Equals(given interface{})
Equals asserts inequality to a given value
func (*Negation) HaveLength ¶
HaveLength is equivalent to HasLength()
func (*Negation) Not ¶
func (not *Negation) Not() Expectation
Not returns a negation of the current expectation
func (*Negation) Should ¶
func (not *Negation) Should() Expectation
Should returns the current expectation
type Transformation ¶
type Transformation func(interface{}) interface{}
Transformation is a function that modifies the thing under test
type UnitTest ¶
UnitTest provides utilities for unit testing
func (*UnitTest) CaptureLogs ¶
func (unit *UnitTest) CaptureLogs(consumer LogsConsumer) (stdout []*LogExpectation, stderr []*LogExpectation)
CaptureLogs creates a list of expectations from logs
func (*UnitTest) Expect ¶
func (unit *UnitTest) Expect(actual interface{}) Expectation
Expect returns a new value-based expectation
func (*UnitTest) ExpectExitCode ¶
func (unit *UnitTest) ExpectExitCode(act Action) Expectation
ExpectExitCode overrides the scaffolding osExit function
func (*UnitTest) ExpectFile ¶
func (unit *UnitTest) ExpectFile(file *os.File) Expectation
ExpectFile returns expectations based on file contents
func (*UnitTest) ExpectOutput ¶
func (unit *UnitTest) ExpectOutput(consumer FileConsumer) Expectation
ExpectOutput returns a new output file-based expectation
type ValueExpectation ¶
ValueExpectation is an expectation based on a realized value
func (*ValueExpectation) Be ¶
func (e *ValueExpectation) Be() Expectation
Be returns the current expectation
func (*ValueExpectation) Empty ¶
func (e *ValueExpectation) Empty()
Empty asserts the value has length 0
func (*ValueExpectation) Equal ¶
func (e *ValueExpectation) Equal(expected interface{})
Equal is equivalent to Equals()
func (*ValueExpectation) EqualTo ¶
func (e *ValueExpectation) EqualTo(expected interface{})
EqualTo is equivalent to Equals()
func (*ValueExpectation) Equals ¶
func (e *ValueExpectation) Equals(expected interface{})
Equals asserts equality to an expected value
func (*ValueExpectation) False ¶
func (e *ValueExpectation) False()
False asserts the value is false
func (*ValueExpectation) HasLength ¶
func (e *ValueExpectation) HasLength(expected int)
HasLength asserts the value is an array with a given length
func (*ValueExpectation) HaveLength ¶
func (e *ValueExpectation) HaveLength(expected int)
HaveLength is equivalent to HasLength()
func (*ValueExpectation) Is ¶
func (e *ValueExpectation) Is() Expectation
Is returns the current expectation
func (*ValueExpectation) Match ¶
func (e *ValueExpectation) Match(pattern string)
Match is equivalent to Matches()
func (*ValueExpectation) Matches ¶
func (e *ValueExpectation) Matches(pattern string)
Matches asserts the value matches a pattern
func (*ValueExpectation) Not ¶
func (e *ValueExpectation) Not() Expectation
Not returns a negation of the current expectation
func (*ValueExpectation) Should ¶
func (e *ValueExpectation) Should() Expectation
Should returns the current expectation
func (*ValueExpectation) To ¶
func (e *ValueExpectation) To() Expectation
To returns the current expectation