Documentation ¶
Index ¶
- Constants
- Variables
- func CreateNumberMatcher(input string) (types.GomegaMatcher, error)
- func CreateStringMatcher(input string) (types.GomegaMatcher, error)
- func IsBaseType(node Node) bool
- func IsBaseTypes(nodes []Node) bool
- func IsObjects(nodes []Node) bool
- func MatchArrayWithArray(path string, exp, act []Node, parser Parser) (types.GomegaMatcher, bool, error)
- func MatchArrayWithString(path string, exp Node, act []Node) (types.GomegaMatcher, bool, error)
- func NewTimestampMatcher(expected time.Time, threshold time.Duration) types.GomegaMatcher
- func ParseTime(str string) (time.Time, error)
- func Replace(data []byte, vars map[string]string) ([]byte, error)
- func Walk(path string, exp, act Node, parser Parser) (types.GomegaMatcher, bool, error)
- type FailureMatcher
- type JSONParser
- type Node
- type Nodes
- type Parser
- type SuccessMatcher
- type TimestampMatcher
- type ValueType
Constants ¶
const ( NotExist = ValueType(iota) String Number Object Array Boolean Null )
const (
// KeyID is used to identify elements in an array
KeyID = "_gst_id"
)
Variables ¶
var ( // JSONParserInstance is a singleton. JSONParserInstance = &JSONParser{} )
var SuccessMatcherInstance = &SuccessMatcher{}
SuccessMatcherInstance is a singleton of SuccessMatcher.
Functions ¶
func CreateNumberMatcher ¶
func CreateNumberMatcher(input string) (types.GomegaMatcher, error)
CreateNumberMatcher returns a matcher for numbers. input must be a function.
func CreateStringMatcher ¶
func CreateStringMatcher(input string) (types.GomegaMatcher, error)
CreateStringMatcher returns a matcher for string. input must be either a plain string or a function.
func IsBaseTypes ¶
IsObjects returns true if all elements in nodes has base type.
func MatchArrayWithArray ¶
func MatchArrayWithArray(path string, exp, act []Node, parser Parser) (types.GomegaMatcher, bool, error)
MatchArrayWithArray matches act with exp as plain arrays.
func MatchArrayWithString ¶
MatchArrayWithArray matches act with exp. exp must be a function.
func NewTimestampMatcher ¶
NewTimestampMatcher returns a matcher that checks datatype.Timestamp and `expected` is within `threshold`.
Types ¶
type FailureMatcher ¶
type FailureMatcher struct {
Message string
}
FailureMatcher always fails. It is used to report custom error messages.
func NewFailureMatcher ¶
func NewFailureMatcher(path, expected, actual string) *FailureMatcher
NewFailureMatcher returns a new *FailureMatcher.
func (*FailureMatcher) FailureMessage ¶
func (matcher *FailureMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage implements types.GomegaMatcher.
func (*FailureMatcher) Match ¶
func (matcher *FailureMatcher) Match(actual interface{}) (success bool, err error)
Match implements types.GomegaMatcher.
func (*FailureMatcher) NegatedFailureMessage ¶
func (matcher *FailureMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage implements types.GomegaMatcher.
type JSONParser ¶
type JSONParser struct { }
JSONParser is parser for JSON.
func (*JSONParser) Delete ¶
func (p *JSONParser) Delete(data []byte, key string) []byte
Delete implements Parser.
func (*JSONParser) GetArray ¶
func (p *JSONParser) GetArray(data []byte) []Node
GetArray implements Parser.
func (*JSONParser) GetFields ¶
func (p *JSONParser) GetFields(data []byte) map[string]Node
GetFields implements Parser.
func (*JSONParser) ValidateObject ¶
func (p *JSONParser) ValidateObject(data []byte) error
ValidateObject implements Parser.
type Parser ¶
type Parser interface { ValidateObject(data []byte) error GetFields(data []byte) map[string]Node GetArray(data []byte) []Node Delete(data []byte, key string) []byte }
Parser represents a parser for data types.
type SuccessMatcher ¶
type SuccessMatcher struct { }
SuccessMatcher always succeeds. It is used as a placeholder for success matches.
func (*SuccessMatcher) FailureMessage ¶
func (matcher *SuccessMatcher) FailureMessage(actual interface{}) (message string)
FailureMessage implements types.GomegaMatcher.
func (*SuccessMatcher) Match ¶
func (matcher *SuccessMatcher) Match(actual interface{}) (success bool, err error)
Match implements types.GomegaMatcher.
func (*SuccessMatcher) NegatedFailureMessage ¶
func (matcher *SuccessMatcher) NegatedFailureMessage(actual interface{}) (message string)
NegatedFailureMessage implements types.GomegaMatcher.
type TimestampMatcher ¶
type TimestampMatcher struct {
// contains filtered or unexported fields
}
TimestampMatcher matches timestamps.
func (*TimestampMatcher) FailureMessage ¶
func (matcher *TimestampMatcher) FailureMessage(actual interface{}) string
FailureMessage returns failure message.
func (*TimestampMatcher) Match ¶
func (matcher *TimestampMatcher) Match(actual interface{}) (bool, error)
Match matches a `string` formatted with RFC3339Nano.
func (*TimestampMatcher) NegatedFailureMessage ¶
func (matcher *TimestampMatcher) NegatedFailureMessage(actual interface{}) string
NegatedFailureMessage returns negated failure message.