Documentation ¶
Overview ¶
Package tort implements an simple assertions testing framework for Go.
Index ¶
- type A
- type ArrayAssertions
- type Assertions
- func (assert Assertions) Array(value interface{}) ArrayAssertions
- func (assert Assertions) Bool(value bool) BoolAssertions
- func (assert Assertions) Duration(value time.Duration) DurationAssertions
- func (assert Assertions) Error(err error) ErrorAssertions
- func (assert Assertions) Failed(format string, args ...interface{})
- func (assert Assertions) False(val bool, msg ...string)
- func (assert Assertions) Fatal(format string, args ...interface{})
- func (assert Assertions) Float32(value float32) Float32Assertions
- func (assert Assertions) Float64(value float64) Float64Assertions
- func (assert Assertions) Int(value int) IntAssertions
- func (assert Assertions) Int16(value int16) Int16Assertions
- func (assert Assertions) Int32(value int32) Int32Assertions
- func (assert Assertions) Int64(value int64) Int64Assertions
- func (assert Assertions) Int8(value int8) Int8Assertions
- func (assert Assertions) IsFalse(val bool, msg ...string)
- func (assert Assertions) IsNil(val interface{}, msg ...string)
- func (assert Assertions) IsNotNil(val interface{}, msg ...string)
- func (assert Assertions) IsTrue(val bool, msg ...string)
- func (assert Assertions) Len(value interface{}) LenAssertions
- func (assert Assertions) Map(value interface{}) MapAssertions
- func (assert Assertions) Nil(val interface{}, msg ...string)
- func (assert Assertions) NotNil(val interface{}, msg ...string)
- func (assert Assertions) Slice(value interface{}) SliceAssertions
- func (assert Assertions) String(value string) StringAssertions
- func (assert Assertions) Struct(obj interface{}) StructAssertions
- func (assert Assertions) Time(value time.Time) TimeAssertions
- func (assert Assertions) True(val bool, msg ...string)
- func (assert Assertions) Uint(value uint) UintAssertions
- func (assert Assertions) Uint16(value uint16) Uint16Assertions
- func (assert Assertions) Uint32(value uint32) Uint32Assertions
- func (assert Assertions) Uint64(value uint64) Uint64Assertions
- func (assert Assertions) Uint8(value uint8) Uint8Assertions
- func (assert Assertions) Valid(err error) ValidatorAssertions
- func (assert Assertions) When(msg ...string) Assertions
- func (assert Assertions) With(msg string, fn func(A))
- type BoolAssertions
- type DurationAssertions
- type ErrorAssertions
- func (assert ErrorAssertions) Equals(expected error)
- func (assert ErrorAssertions) Is(expected error)
- func (assert ErrorAssertions) IsNil(msg ...string)
- func (assert ErrorAssertions) IsNot(expected error)
- func (assert ErrorAssertions) IsNotNil(msg ...string)
- func (assert ErrorAssertions) Nil(msg ...string)
- func (assert ErrorAssertions) NotEquals(expected error)
- func (assert ErrorAssertions) NotNil(msg ...string)
- type Float32Assertions
- type Float64Assertions
- type Int16Assertions
- type Int32Assertions
- type Int64Assertions
- type Int8Assertions
- type IntAssertions
- type LenAssertions
- type MapAssertions
- func (assert MapAssertions) Element(key interface{}) reflect.Value
- func (assert MapAssertions) Empty()
- func (assert MapAssertions) FewerThan(expected int)
- func (assert MapAssertions) HasKey(key interface{})
- func (assert MapAssertions) Length(expected int)
- func (assert MapAssertions) MoreThan(expected int)
- type SliceAssertions
- func (assert SliceAssertions) Bool(idx int) BoolAssertions
- func (assert SliceAssertions) Duration(idx int) DurationAssertions
- func (assert SliceAssertions) Element(idx int) reflect.Value
- func (assert SliceAssertions) Empty()
- func (assert SliceAssertions) FewerThan(expected int)
- func (assert SliceAssertions) Float32(idx int) Float32Assertions
- func (assert SliceAssertions) Float64(idx int) Float64Assertions
- func (assert SliceAssertions) Int(idx int) IntAssertions
- func (assert SliceAssertions) Int16(idx int) Int16Assertions
- func (assert SliceAssertions) Int32(idx int) Int32Assertions
- func (assert SliceAssertions) Int64(idx int) Int64Assertions
- func (assert SliceAssertions) Int8(idx int) Int8Assertions
- func (assert SliceAssertions) Len(idx int) LenAssertions
- func (assert SliceAssertions) Length(expected int)
- func (assert SliceAssertions) MoreThan(expected int)
- func (assert SliceAssertions) String(idx int) StringAssertions
- func (assert SliceAssertions) Struct(idx int) StructAssertions
- func (assert SliceAssertions) Time(idx int) TimeAssertions
- func (assert SliceAssertions) Uint(idx int) UintAssertions
- func (assert SliceAssertions) Uint16(idx int) Uint16Assertions
- func (assert SliceAssertions) Uint32(idx int) Uint32Assertions
- func (assert SliceAssertions) Uint64(idx int) Uint64Assertions
- func (assert SliceAssertions) Uint8(idx int) Uint8Assertions
- type StringAssertions
- func (assert StringAssertions) Blank()
- func (assert StringAssertions) Contains(other string)
- func (assert StringAssertions) Empty()
- func (assert StringAssertions) EndsWith(other string)
- func (assert StringAssertions) Equals(other string)
- func (assert StringAssertions) IsBlank()
- func (assert StringAssertions) IsNotBlank()
- func (assert StringAssertions) Matches(expr string)
- func (assert StringAssertions) NotBlank()
- func (assert StringAssertions) NotContains(other string)
- func (assert StringAssertions) NotEmpty()
- func (assert StringAssertions) NotEquals(other string)
- func (assert StringAssertions) NotMatches(expr string)
- func (assert StringAssertions) StartsWith(other string)
- type StructAssertions
- func (assert StructAssertions) Bool(field string) BoolAssertions
- func (assert StructAssertions) Duration(field string) DurationAssertions
- func (assert StructAssertions) Field(name string) reflect.Value
- func (assert StructAssertions) Float32(field string) Float32Assertions
- func (assert StructAssertions) Float64(field string) Float64Assertions
- func (assert StructAssertions) Int(field string) IntAssertions
- func (assert StructAssertions) Int16(field string) Int16Assertions
- func (assert StructAssertions) Int32(field string) Int32Assertions
- func (assert StructAssertions) Int64(field string) Int64Assertions
- func (assert StructAssertions) Int8(field string) Int8Assertions
- func (assert StructAssertions) IsNil()
- func (assert StructAssertions) IsNotNil()
- func (assert StructAssertions) Len(field string) LenAssertions
- func (assert StructAssertions) Map(field string) MapAssertions
- func (assert StructAssertions) Slice(field string) SliceAssertions
- func (assert StructAssertions) String(field string) StringAssertions
- func (assert StructAssertions) Struct(field string) StructAssertions
- func (assert StructAssertions) Time(field string) TimeAssertions
- func (assert StructAssertions) Type() string
- func (assert StructAssertions) Uint(field string) UintAssertions
- func (assert StructAssertions) Uint16(field string) Uint16Assertions
- func (assert StructAssertions) Uint32(field string) Uint32Assertions
- func (assert StructAssertions) Uint64(field string) Uint64Assertions
- func (assert StructAssertions) Uint8(field string) Uint8Assertions
- type TimeAssertion
- type TimeAssertions
- func (assert TimeAssertions) After(other time.Time)
- func (assert TimeAssertions) Before(other time.Time)
- func (assert TimeAssertions) Equals(other time.Time)
- func (assert TimeAssertions) IsNotSet()
- func (assert TimeAssertions) IsSet()
- func (assert TimeAssertions) NotEquals(other time.Time)
- func (assert TimeAssertions) Within(dur time.Duration)
- type Uint16Assertions
- type Uint32Assertions
- type Uint64Assertions
- type Uint8Assertions
- type UintAssertions
- type ValidatorAssertions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A ¶
type A struct {
Assertions
}
A provides an alias shortcut for assertions. Makes it easier to use the With function in test cases.
type ArrayAssertions ¶
type ArrayAssertions struct { Assertions // contains filtered or unexported fields }
ArrayAssertions are tests around array values.
type Assertions ¶
type Assertions struct {
// contains filtered or unexported fields
}
Assertions are the base set of assertions.
func For ¶
func For(tb testing.TB) Assertions
For initializes the Tort assertions for a test case or benchmark.
func NewAssertions ¶
func NewAssertions(t testing.TB) Assertions
NewAssertions creates a new Assertions object to use for a test case.
func (Assertions) Array ¶
func (assert Assertions) Array(value interface{}) ArrayAssertions
func (Assertions) Bool ¶
func (assert Assertions) Bool(value bool) BoolAssertions
Bool identifies a bolean variable value and returns test functions for its values.
func (Assertions) Duration ¶
func (assert Assertions) Duration(value time.Duration) DurationAssertions
Duration identifies a time.Duration variable value and returns test functions for its values.
func (Assertions) Error ¶
func (assert Assertions) Error(err error) ErrorAssertions
Error assists in validating errors occurred.
func (Assertions) Failed ¶
func (assert Assertions) Failed(format string, args ...interface{})
Failed outputs the final error message to *testing.T.
func (Assertions) False ¶ added in v1.2.3
func (assert Assertions) False(val bool, msg ...string)
False confirms the value is false. If not, generates an error.
func (Assertions) Fatal ¶
func (assert Assertions) Fatal(format string, args ...interface{})
Fatal outputs the final error message to *testing.T and exits.
func (Assertions) Float32 ¶
func (assert Assertions) Float32(value float32) Float32Assertions
Float32 identifies an float variable value and returns test functions for its values.
func (Assertions) Float64 ¶
func (assert Assertions) Float64(value float64) Float64Assertions
Float64 identifies an float variable value and returns test functions for its values.
func (Assertions) Int ¶
func (assert Assertions) Int(value int) IntAssertions
Int identifies an integer variable value and returns test functions for its values.
func (Assertions) Int16 ¶
func (assert Assertions) Int16(value int16) Int16Assertions
Int16 identifies an integer variable value and returns test functions for its values.
func (Assertions) Int32 ¶
func (assert Assertions) Int32(value int32) Int32Assertions
Int32 identifies an integer variable value and returns test functions for its values.
func (Assertions) Int64 ¶
func (assert Assertions) Int64(value int64) Int64Assertions
Int64 identifies an integer variable value and returns test functions for its values.
func (Assertions) Int8 ¶
func (assert Assertions) Int8(value int8) Int8Assertions
Int8 identifies an integer variable value and returns test functions for its values.
func (Assertions) IsFalse ¶ added in v1.1.1
func (assert Assertions) IsFalse(val bool, msg ...string)
IsFalse confirms the value is false. If not, generates an error.
func (Assertions) IsNil ¶
func (assert Assertions) IsNil(val interface{}, msg ...string)
IsNil checks if the value is nil. If not, generates an error.
func (Assertions) IsNotNil ¶
func (assert Assertions) IsNotNil(val interface{}, msg ...string)
IsNotNil checks that the value is not nil. If it is, generates an error.
func (Assertions) IsTrue ¶ added in v1.1.1
func (assert Assertions) IsTrue(val bool, msg ...string)
IsTrue confirms the value is true. If not, generates an error.
func (Assertions) Len ¶ added in v1.2.0
func (assert Assertions) Len(value interface{}) LenAssertions
Len identifies an object than can have length, and stores the length as its integer value so it can be compared.
func (Assertions) Map ¶ added in v1.2.0
func (assert Assertions) Map(value interface{}) MapAssertions
Map identifies a map variable value and returns test functions for its values. If the value isn't a map, generates a fatal error.
func (Assertions) Nil ¶ added in v1.2.3
func (assert Assertions) Nil(val interface{}, msg ...string)
Nil checks if the value is nil. If not, generates an error.
func (Assertions) NotNil ¶ added in v1.2.3
func (assert Assertions) NotNil(val interface{}, msg ...string)
NotNil checks that the value is not nil. If it is, generates an error.
func (Assertions) Slice ¶
func (assert Assertions) Slice(value interface{}) SliceAssertions
Slice identifies a slice variable value and returns test functions for its values. If the value isn't a slice, generates a fatal error.
func (Assertions) String ¶
func (assert Assertions) String(value string) StringAssertions
String identifies a string variable value and returns test functions for its values.
func (Assertions) Struct ¶
func (assert Assertions) Struct(obj interface{}) StructAssertions
Struct identifies assertions about an object.
func (Assertions) Time ¶
func (assert Assertions) Time(value time.Time) TimeAssertions
Time identifies a time.Time variable value and returns test functions for its values.
func (Assertions) True ¶ added in v1.2.3
func (assert Assertions) True(val bool, msg ...string)
True confirms the value is true. If not, generates an error.
func (Assertions) Uint ¶
func (assert Assertions) Uint(value uint) UintAssertions
Uint identifies an integer variable value and returns test functions for its values.
func (Assertions) Uint16 ¶
func (assert Assertions) Uint16(value uint16) Uint16Assertions
Uint16 identifies an integer variable value and returns test functions for its values.
func (Assertions) Uint32 ¶
func (assert Assertions) Uint32(value uint32) Uint32Assertions
Uint32 identifies an integer variable value and returns test functions for its values.
func (Assertions) Uint64 ¶
func (assert Assertions) Uint64(value uint64) Uint64Assertions
Uint64 identifies an integer variable value and returns test functions for its values.
func (Assertions) Uint8 ¶
func (assert Assertions) Uint8(value uint8) Uint8Assertions
Uint8 identifies an integer variable value and returns test functions for its values.
func (Assertions) Valid ¶ added in v1.1.0
func (assert Assertions) Valid(err error) ValidatorAssertions
Valid assists in validating validation errors,
func (Assertions) When ¶
func (assert Assertions) When(msg ...string) Assertions
When describes something about the assertion, e.g. assert.When("creating a user").
func (Assertions) With ¶
func (assert Assertions) With(msg string, fn func(A))
With is like When, except that the assertion is passed to a function for processing.
type BoolAssertions ¶
type BoolAssertions struct { Assertions // contains filtered or unexported fields }
BoolAssertions are tests around boolean values.
func (BoolAssertions) Equals ¶
func (assert BoolAssertions) Equals(val bool)
func (BoolAssertions) False ¶ added in v1.2.2
func (assert BoolAssertions) False()
False generates an error if the boolean value is true.
func (BoolAssertions) IsFalse ¶
func (assert BoolAssertions) IsFalse()
IsFalse generates an error if the boolean value is true.
func (BoolAssertions) IsTrue ¶
func (assert BoolAssertions) IsTrue()
IsTrue generates an error if the boolean value is false.
func (BoolAssertions) True ¶ added in v1.2.2
func (assert BoolAssertions) True()
True generates an error if the boolean value is false.
type DurationAssertions ¶
type DurationAssertions struct { Assertions // contains filtered or unexported fields }
DurationAssertions are tests around duration values.
func (DurationAssertions) Equals ¶
func (assert DurationAssertions) Equals(other time.Duration)
Equals generates an error if the duration does not equal the other..
func (DurationAssertions) GreaterThan ¶
func (assert DurationAssertions) GreaterThan(other time.Duration)
GreaterThan generates an error if the duration is less than or equal to the other..
func (DurationAssertions) LessThan ¶
func (assert DurationAssertions) LessThan(other time.Duration)
LessThan generates an error if the duration is greater than or equal to the other..
func (DurationAssertions) NotEquals ¶
func (assert DurationAssertions) NotEquals(other time.Duration)
NotEquals generates an error if the duration equals the other..
type ErrorAssertions ¶
type ErrorAssertions struct { Assertions // contains filtered or unexported fields }
ErrorAssertions test errors.
func (ErrorAssertions) Equals ¶
func (assert ErrorAssertions) Equals(expected error)
Equals checks that the expected error was generated.
func (ErrorAssertions) Is ¶
func (assert ErrorAssertions) Is(expected error)
Is checks the error is this kind of error.
func (ErrorAssertions) IsNil ¶
func (assert ErrorAssertions) IsNil(msg ...string)
IsNil generates an error message if the error isn't nil.
func (ErrorAssertions) IsNot ¶
func (assert ErrorAssertions) IsNot(expected error)
IsNot checks if the error is not this kind of error.
func (ErrorAssertions) IsNotNil ¶
func (assert ErrorAssertions) IsNotNil(msg ...string)
IsNotNil generates an error message when the error is nil.
func (ErrorAssertions) Nil ¶ added in v1.2.2
func (assert ErrorAssertions) Nil(msg ...string)
Nil generates an error message if the error isn't nil.
func (ErrorAssertions) NotEquals ¶
func (assert ErrorAssertions) NotEquals(expected error)
NotEquals checks that the given error was not generated.
func (ErrorAssertions) NotNil ¶ added in v1.2.2
func (assert ErrorAssertions) NotNil(msg ...string)
NotNil generates an error message when the error is nil.
type Float32Assertions ¶
type Float32Assertions struct { Assertions // contains filtered or unexported fields }
Float32Assertions are tests around float (float32) values.
func (Float32Assertions) Equals ¶
func (assert Float32Assertions) Equals(other float32)
Equals generates an error if the float value isn't the same as other.
func (Float32Assertions) GreaterThan ¶
func (assert Float32Assertions) GreaterThan(other float32)
GreaterThan generates an error if the float value is less than or equal to the other.
func (Float32Assertions) LessThan ¶
func (assert Float32Assertions) LessThan(other float32)
LessThan generates an error if the float value is greater than or equal to the other.
func (Float32Assertions) NotEquals ¶
func (assert Float32Assertions) NotEquals(other float32)
Equals generates an error if the float value is the same as the other.
type Float64Assertions ¶
type Float64Assertions struct { Assertions // contains filtered or unexported fields }
Float64Assertions are tests around float (float64) values.
func (Float64Assertions) Equals ¶
func (assert Float64Assertions) Equals(other float64)
Equals generates an error if the float value isn't the same as other.
func (Float64Assertions) GreaterThan ¶
func (assert Float64Assertions) GreaterThan(other float64)
GreaterThan generates an error if the float value is less than or equal to the other.
func (Float64Assertions) LessThan ¶
func (assert Float64Assertions) LessThan(other float64)
LessThan generates an error if the float value is greater than or equal to the other.
func (Float64Assertions) NotEquals ¶
func (assert Float64Assertions) NotEquals(other float64)
Equals generates an error if the float value is the same as the other.
type Int16Assertions ¶
type Int16Assertions struct { Assertions // contains filtered or unexported fields }
Int16Assertions are tests around integer (int16) values.
func (Int16Assertions) Equals ¶
func (assert Int16Assertions) Equals(other int16)
Equals generates an error if the integer value isn't the same as other.
func (Int16Assertions) GreaterThan ¶
func (assert Int16Assertions) GreaterThan(other int16)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Int16Assertions) LessThan ¶
func (assert Int16Assertions) LessThan(other int16)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Int16Assertions) NotEquals ¶
func (assert Int16Assertions) NotEquals(other int16)
Equals generates an error if the integer value is the same as the other.
type Int32Assertions ¶
type Int32Assertions struct { Assertions // contains filtered or unexported fields }
Int32Assertions are tests around integer (int32) values.
func (Int32Assertions) Equals ¶
func (assert Int32Assertions) Equals(other int32)
Equals generates an error if the integer value isn't the same as other.
func (Int32Assertions) GreaterThan ¶
func (assert Int32Assertions) GreaterThan(other int32)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Int32Assertions) LessThan ¶
func (assert Int32Assertions) LessThan(other int32)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Int32Assertions) NotEquals ¶
func (assert Int32Assertions) NotEquals(other int32)
Equals generates an error if the integer value is the same as the other.
type Int64Assertions ¶
type Int64Assertions struct { Assertions // contains filtered or unexported fields }
Int64Assertions are tests around integer (int64) values.
func (Int64Assertions) Equals ¶
func (assert Int64Assertions) Equals(other int64)
Equals generates an error if the integer value isn't the same as other.
func (Int64Assertions) GreaterThan ¶
func (assert Int64Assertions) GreaterThan(other int64)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Int64Assertions) LessThan ¶
func (assert Int64Assertions) LessThan(other int64)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Int64Assertions) NotEquals ¶
func (assert Int64Assertions) NotEquals(other int64)
Equals generates an error if the integer value is the same as the other.
type Int8Assertions ¶
type Int8Assertions struct { Assertions // contains filtered or unexported fields }
Int8Assertions are tests around integer (int8) values.
func (Int8Assertions) Equals ¶
func (assert Int8Assertions) Equals(other int8)
Equals generates an error if the integer value isn't the same as other.
func (Int8Assertions) GreaterThan ¶
func (assert Int8Assertions) GreaterThan(other int8)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Int8Assertions) LessThan ¶
func (assert Int8Assertions) LessThan(other int8)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Int8Assertions) NotEquals ¶
func (assert Int8Assertions) NotEquals(other int8)
Equals generates an error if the integer value is the same as the other.
type IntAssertions ¶
type IntAssertions struct { Assertions // contains filtered or unexported fields }
IntAssertions are tests around integer (int) values.
func (IntAssertions) Equals ¶
func (assert IntAssertions) Equals(other int)
Equals generates an error if the integer value isn't the same as other.
func (IntAssertions) GreaterThan ¶
func (assert IntAssertions) GreaterThan(other int)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (IntAssertions) LessThan ¶
func (assert IntAssertions) LessThan(other int)
LessThan generates an error if the integer value is greater than or equal to the other.
func (IntAssertions) NotEquals ¶
func (assert IntAssertions) NotEquals(other int)
Equals generates an error if the integer value is the same as the other.
type LenAssertions ¶ added in v1.2.0
type LenAssertions struct { Assertions // contains filtered or unexported fields }
LenAssertions are tests around the length of strings, arrays, slices, and maps.
func (LenAssertions) Equals ¶ added in v1.2.0
func (assert LenAssertions) Equals(other int)
Equals generates an error if the length value isn't the same as other.
func (LenAssertions) GreaterThan ¶ added in v1.2.0
func (assert LenAssertions) GreaterThan(other int)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (LenAssertions) LessThan ¶ added in v1.2.0
func (assert LenAssertions) LessThan(other int)
LessThan generates an error if the integer value is greater than or equal to the other.
func (LenAssertions) NotEquals ¶ added in v1.2.0
func (assert LenAssertions) NotEquals(other int)
NotEquals generates an error if the length value is the same as the other.
type MapAssertions ¶ added in v1.2.0
type MapAssertions struct { Assertions // contains filtered or unexported fields }
MapAssertions are tests around map values.
func (MapAssertions) Element ¶ added in v1.2.0
func (assert MapAssertions) Element(key interface{}) reflect.Value
Element looks up the element from the map.
func (MapAssertions) Empty ¶ added in v1.2.0
func (assert MapAssertions) Empty()
Empty generates an error if the length of the map is not zero.
func (MapAssertions) FewerThan ¶ added in v1.2.0
func (assert MapAssertions) FewerThan(expected int)
FewerThan generates an error if the length of the map equals or exceeds the value supplied.
func (MapAssertions) HasKey ¶ added in v1.2.0
func (assert MapAssertions) HasKey(key interface{})
func (MapAssertions) Length ¶ added in v1.2.0
func (assert MapAssertions) Length(expected int)
Length generates an error if the length of the map doesn't equal the value supplied.
func (MapAssertions) MoreThan ¶ added in v1.2.0
func (assert MapAssertions) MoreThan(expected int)
MoreThan generates an error if the length of the map doesn't exceed the value supplied.
type SliceAssertions ¶
type SliceAssertions struct { Assertions // contains filtered or unexported fields }
SliceAssertions are tests around slice values.
func (SliceAssertions) Bool ¶
func (assert SliceAssertions) Bool(idx int) BoolAssertions
Bool looks up an element in a slice expecting it to be a bool.
func (SliceAssertions) Duration ¶
func (assert SliceAssertions) Duration(idx int) DurationAssertions
Duration identifies a duration element in the slace. If the element isn't present, or isn't a time.Duration, generates an error.
func (SliceAssertions) Element ¶
func (assert SliceAssertions) Element(idx int) reflect.Value
Element looks up the element from the slice array.
func (SliceAssertions) Empty ¶
func (assert SliceAssertions) Empty()
Empty generates an error if the length of the slice is not zero.
func (SliceAssertions) FewerThan ¶
func (assert SliceAssertions) FewerThan(expected int)
FewerThan generates an error if the length of the slice equals or exceeds the value supplied.
func (SliceAssertions) Float32 ¶
func (assert SliceAssertions) Float32(idx int) Float32Assertions
Float looks for the given float element, confirms it's an float32, and returns the assertions valid for the float.
func (SliceAssertions) Float64 ¶
func (assert SliceAssertions) Float64(idx int) Float64Assertions
Float looks for the given float element, confirms it's an float64, and returns the assertions valid for the float.
func (SliceAssertions) Int ¶
func (assert SliceAssertions) Int(idx int) IntAssertions
Int looks for the given slice element, confirms it's an int, and returns the assertions valid for the integer.
func (SliceAssertions) Int16 ¶
func (assert SliceAssertions) Int16(idx int) Int16Assertions
Int16 looks for the given slice element, confirms it's an int16, and returns the assertions valid for the integer.
func (SliceAssertions) Int32 ¶
func (assert SliceAssertions) Int32(idx int) Int32Assertions
Int32 looks for the given slice element, confirms it's an int32, and returns the assertions valid for the integer.
func (SliceAssertions) Int64 ¶
func (assert SliceAssertions) Int64(idx int) Int64Assertions
Int64 looks for the given slice element, confirms it's an int64, and returns the assertions valid for the integer.
func (SliceAssertions) Int8 ¶
func (assert SliceAssertions) Int8(idx int) Int8Assertions
Int8 looks for the given slice element, confirms it's an int8, and returns the assertions valid for the integer.
func (SliceAssertions) Len ¶ added in v1.2.0
func (assert SliceAssertions) Len(idx int) LenAssertions
Len looks for the given slice element, confirms it has length, and returns the assertions valid for the length as an integer.
func (SliceAssertions) Length ¶
func (assert SliceAssertions) Length(expected int)
Length generates an error if the length of the slice doesn't equal the value supplied.
func (SliceAssertions) MoreThan ¶
func (assert SliceAssertions) MoreThan(expected int)
MoreThan generates an error if the length of the slice doesn't exceed the value supplied.
func (SliceAssertions) String ¶
func (assert SliceAssertions) String(idx int) StringAssertions
String looks up an element in a slice expecting it to be a string.
func (SliceAssertions) Struct ¶
func (assert SliceAssertions) Struct(idx int) StructAssertions
Struct looks up an element in a slice expecting it to be a struct or a pointer to a struct.
func (SliceAssertions) Time ¶
func (assert SliceAssertions) Time(idx int) TimeAssertions
String looks up an element in a slice expecting it to be a time.Time, or fulfills TimeAssertion.
func (SliceAssertions) Uint ¶
func (assert SliceAssertions) Uint(idx int) UintAssertions
Int looks for the given slice element, confirms it's an int, and returns the assertions valid for the integer.
func (SliceAssertions) Uint16 ¶
func (assert SliceAssertions) Uint16(idx int) Uint16Assertions
Int16 looks for the given slice element, confirms it's an int16, and returns the assertions valid for the integer.
func (SliceAssertions) Uint32 ¶
func (assert SliceAssertions) Uint32(idx int) Uint32Assertions
Int32 looks for the given slice element, confirms it's an int32, and returns the assertions valid for the integer.
func (SliceAssertions) Uint64 ¶
func (assert SliceAssertions) Uint64(idx int) Uint64Assertions
Int64 looks for the given slice element, confirms it's an int64, and returns the assertions valid for the integer.
func (SliceAssertions) Uint8 ¶
func (assert SliceAssertions) Uint8(idx int) Uint8Assertions
Int8 looks for the given slice element, confirms it's an int8, and returns the assertions valid for the integer.
type StringAssertions ¶
type StringAssertions struct { Assertions // contains filtered or unexported fields }
StringAssertions are tests around string values.
func (StringAssertions) Blank ¶
func (assert StringAssertions) Blank()
Blank generates an error if the string is not empty with something other than whitespace.
func (StringAssertions) Contains ¶
func (assert StringAssertions) Contains(other string)
Contains generates an error if the other value isn't present somewhere in the string.
func (StringAssertions) Empty ¶
func (assert StringAssertions) Empty()
Empty generates an error if the string contains any characters, including whitespace.
func (StringAssertions) EndsWith ¶ added in v1.2.4
func (assert StringAssertions) EndsWith(other string)
EndsWith generates an error if the other value isn't present at the end of the string.
func (StringAssertions) Equals ¶
func (assert StringAssertions) Equals(other string)
Equals generates an error if the string value isn't the same as other.
func (StringAssertions) IsBlank ¶ added in v1.1.1
func (assert StringAssertions) IsBlank()
IsBlank is an alias for Blank.
func (StringAssertions) IsNotBlank ¶ added in v1.1.1
func (assert StringAssertions) IsNotBlank()
IsNotBlank is an alias for NotBlank.
func (StringAssertions) Matches ¶
func (assert StringAssertions) Matches(expr string)
Matches generates an error if the string value doesn't match the regular expression.
func (StringAssertions) NotBlank ¶
func (assert StringAssertions) NotBlank()
NotBlank generates an error if the string is empty or contains only whitespace.
func (StringAssertions) NotContains ¶
func (assert StringAssertions) NotContains(other string)
NotContains generates an error if the other value is present somewhere in the string.
func (StringAssertions) NotEmpty ¶
func (assert StringAssertions) NotEmpty()
NotEmpty generates an error if the string does not contain any characters, including whitespace.
func (StringAssertions) NotEquals ¶
func (assert StringAssertions) NotEquals(other string)
NotEquals generates an error if the string value is the same as the other.
func (StringAssertions) NotMatches ¶
func (assert StringAssertions) NotMatches(expr string)
NotMatches generates an error if the string value matches the regular expression.
func (StringAssertions) StartsWith ¶ added in v1.2.4
func (assert StringAssertions) StartsWith(other string)
StartsWith generates an error if the other value isn't present at the beginning of the string.
type StructAssertions ¶
type StructAssertions struct { Assertions // contains filtered or unexported fields }
StructAssertions test object properties.
func (StructAssertions) Bool ¶
func (assert StructAssertions) Bool(field string) BoolAssertions
Bool identifies a boolean field on a struct. If the field isn't present, or isn't a bool, generates an error.
func (StructAssertions) Duration ¶
func (assert StructAssertions) Duration(field string) DurationAssertions
Duration identifies a duration field on a struct. If the field isn't present, or isn't a time.Duration, generates an error.
func (StructAssertions) Field ¶
func (assert StructAssertions) Field(name string) reflect.Value
Field verifies a field exists and returns it.
func (StructAssertions) Float32 ¶
func (assert StructAssertions) Float32(field string) Float32Assertions
Float looks for the given struct field, confirms it's an float32, and returns the assertions valid for the float.
func (StructAssertions) Float64 ¶
func (assert StructAssertions) Float64(field string) Float64Assertions
Float looks for the given struct field, confirms it's an float64, and returns the assertions valid for the float.
func (StructAssertions) Int ¶
func (assert StructAssertions) Int(field string) IntAssertions
Int looks for the given struct field, confirms it's an int, and returns the assertions valid for the integer.
func (StructAssertions) Int16 ¶
func (assert StructAssertions) Int16(field string) Int16Assertions
Int16 looks for the given struct field, confirms it's an int16, and returns the assertions valid for the integer.
func (StructAssertions) Int32 ¶
func (assert StructAssertions) Int32(field string) Int32Assertions
Int32 looks for the given struct field, confirms it's an int32, and returns the assertions valid for the integer.
func (StructAssertions) Int64 ¶
func (assert StructAssertions) Int64(field string) Int64Assertions
Int64 looks for the given struct field, confirms it's an int64, and returns the assertions valid for the integer.
func (StructAssertions) Int8 ¶
func (assert StructAssertions) Int8(field string) Int8Assertions
Int8 looks for the given struct field, confirms it's an int8, and returns the assertions valid for the integer.
func (StructAssertions) IsNil ¶
func (assert StructAssertions) IsNil()
IsNil returns true if the object was nil.
func (StructAssertions) IsNotNil ¶
func (assert StructAssertions) IsNotNil()
IsNotNil returns true if the object was nil.
func (StructAssertions) Len ¶ added in v1.2.0
func (assert StructAssertions) Len(field string) LenAssertions
Len looks for the given struct field, confirms it has length, and returns the assertions valid for the length as an integer.
func (StructAssertions) Map ¶ added in v1.2.0
func (assert StructAssertions) Map(field string) MapAssertions
Map identifies a map field on a struct. If the field isn't present, or isn't a map, generates an error.
func (StructAssertions) Slice ¶
func (assert StructAssertions) Slice(field string) SliceAssertions
Slice identifies a slice field on a struct. If the field isn't present, or isn't a slice, generates an error.
func (StructAssertions) String ¶
func (assert StructAssertions) String(field string) StringAssertions
String identifies a string field on a struct. If the field isn't present, or isn't a string, generates an error.
func (StructAssertions) Struct ¶
func (assert StructAssertions) Struct(field string) StructAssertions
Struct identifies assertions about an object and returns the assertions around the struct.
func (StructAssertions) Time ¶
func (assert StructAssertions) Time(field string) TimeAssertions
Time identifies a time field on a struct. If the field isn't present, or isn't a time.Time or implements TimeAssertion, generates an error.
func (StructAssertions) Type ¶
func (assert StructAssertions) Type() string
Type returns the name of the struct.
func (StructAssertions) Uint ¶
func (assert StructAssertions) Uint(field string) UintAssertions
Uint looks for the given struct field, confirms it's an uint, and returns the assertions valid for the integer.
func (StructAssertions) Uint16 ¶
func (assert StructAssertions) Uint16(field string) Uint16Assertions
Uint looks for the given struct field, confirms it's an uint16, and returns the assertions valid for the integer.
func (StructAssertions) Uint32 ¶
func (assert StructAssertions) Uint32(field string) Uint32Assertions
Uint looks for the given struct field, confirms it's an uint32, and returns the assertions valid for the integer.
func (StructAssertions) Uint64 ¶
func (assert StructAssertions) Uint64(field string) Uint64Assertions
Uint looks for the given struct field, confirms it's an uint64, and returns the assertions valid for the integer.
func (StructAssertions) Uint8 ¶
func (assert StructAssertions) Uint8(field string) Uint8Assertions
Uint looks for the given struct field, confirms it's an uint8, and returns the assertions valid for the integer.
type TimeAssertion ¶
type TimeAssertion interface { // Assert returns the underlying time.Time value. Assert() time.Time }
TimeAssertion accepts time.Time extensions.
type TimeAssertions ¶
type TimeAssertions struct { Assertions // contains filtered or unexported fields }
TimeAssertions are tests around time values.
func (TimeAssertions) After ¶
func (assert TimeAssertions) After(other time.Time)
Before generates an error if the time is before the other.
func (TimeAssertions) Before ¶
func (assert TimeAssertions) Before(other time.Time)
Before generates an error if the time is after the other.
func (TimeAssertions) Equals ¶
func (assert TimeAssertions) Equals(other time.Time)
Equals generates an error if the two times aren't equal.
func (TimeAssertions) IsNotSet ¶
func (assert TimeAssertions) IsNotSet()
Unset generates an error if the time is not set (is zero).
func (TimeAssertions) IsSet ¶
func (assert TimeAssertions) IsSet()
Set generates an error if the time is set (not zero).
func (TimeAssertions) NotEquals ¶
func (assert TimeAssertions) NotEquals(other time.Time)
Equals generates an error if the two times aren't equal.
func (TimeAssertions) Within ¶
func (assert TimeAssertions) Within(dur time.Duration)
Within generates an error if the time is within the given duration from right now.
type Uint16Assertions ¶
type Uint16Assertions struct { Assertions // contains filtered or unexported fields }
Uint16Assertions are tests around integer (uint16) values.
func (Uint16Assertions) Equals ¶
func (assert Uint16Assertions) Equals(other uint16)
Equals generates an error if the integer value isn't the same as other.
func (Uint16Assertions) GreaterThan ¶
func (assert Uint16Assertions) GreaterThan(other uint16)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Uint16Assertions) LessThan ¶
func (assert Uint16Assertions) LessThan(other uint16)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Uint16Assertions) NotEquals ¶
func (assert Uint16Assertions) NotEquals(other uint16)
Equals generates an error if the integer value is the same as the other.
type Uint32Assertions ¶
type Uint32Assertions struct { Assertions // contains filtered or unexported fields }
Uint32Assertions are tests around integer (uint32) values.
func (Uint32Assertions) Equals ¶
func (assert Uint32Assertions) Equals(other uint32)
Equals generates an error if the integer value isn't the same as other.
func (Uint32Assertions) GreaterThan ¶
func (assert Uint32Assertions) GreaterThan(other uint32)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Uint32Assertions) LessThan ¶
func (assert Uint32Assertions) LessThan(other uint32)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Uint32Assertions) NotEquals ¶
func (assert Uint32Assertions) NotEquals(other uint32)
Equals generates an error if the integer value is the same as the other.
type Uint64Assertions ¶
type Uint64Assertions struct { Assertions // contains filtered or unexported fields }
Uint64Assertions are tests around integer (uint64) values.
func (Uint64Assertions) Equals ¶
func (assert Uint64Assertions) Equals(other uint64)
Equals generates an error if the integer value isn't the same as other.
func (Uint64Assertions) GreaterThan ¶
func (assert Uint64Assertions) GreaterThan(other uint64)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Uint64Assertions) LessThan ¶
func (assert Uint64Assertions) LessThan(other uint64)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Uint64Assertions) NotEquals ¶
func (assert Uint64Assertions) NotEquals(other uint64)
Equals generates an error if the integer value is the same as the other.
type Uint8Assertions ¶
type Uint8Assertions struct { Assertions // contains filtered or unexported fields }
Uint8Assertions are tests around integer (uint8) values.
func (Uint8Assertions) Equals ¶
func (assert Uint8Assertions) Equals(other uint8)
Equals generates an error if the integer value isn't the same as other.
func (Uint8Assertions) GreaterThan ¶
func (assert Uint8Assertions) GreaterThan(other uint8)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (Uint8Assertions) LessThan ¶
func (assert Uint8Assertions) LessThan(other uint8)
LessThan generates an error if the integer value is greater than or equal to the other.
func (Uint8Assertions) NotEquals ¶
func (assert Uint8Assertions) NotEquals(other uint8)
Equals generates an error if the integer value is the same as the other.
type UintAssertions ¶
type UintAssertions struct { Assertions // contains filtered or unexported fields }
UintAssertions are tests around integer (uint) values.
func (UintAssertions) Equals ¶
func (assert UintAssertions) Equals(other uint)
Equals generates an error if the integer value isn't the same as other.
func (UintAssertions) GreaterThan ¶
func (assert UintAssertions) GreaterThan(other uint)
GreaterThan generates an error if the integer value is less than or equal to the other.
func (UintAssertions) LessThan ¶
func (assert UintAssertions) LessThan(other uint)
LessThan generates an error if the integer value is greater than or equal to the other.
func (UintAssertions) NotEquals ¶
func (assert UintAssertions) NotEquals(other uint)
Equals generates an error if the integer value is the same as the other.
type ValidatorAssertions ¶ added in v1.1.0
type ValidatorAssertions struct { Assertions // contains filtered or unexported fields }
ValidatorAssertions test validation errors from https://github.com/go-playground/validator.
func (ValidatorAssertions) For ¶ added in v1.1.0
func (assert ValidatorAssertions) For(field, kind string)
For checks for a validation error matching the field and the kind of error, e.g. "required" or "min". If kind is blank, confirms there was any error on the given field.
func (ValidatorAssertions) IsNil ¶ added in v1.1.0
func (assert ValidatorAssertions) IsNil(msg ...string)
IsNil generates an error message if the error isn't nil.
func (ValidatorAssertions) IsNotNil ¶ added in v1.1.0
func (assert ValidatorAssertions) IsNotNil(msg ...string)
IsNotNil generates an error message when the error is nil.
func (ValidatorAssertions) NotFor ¶ added in v1.1.0
func (assert ValidatorAssertions) NotFor(field, kind string)
NotFor checks that the validation error either doesn't exist, or isn't for the given field and type of error. If kind is blank, just confirms there wasn't an error on the field.