Documentation ¶
Index ¶
- func Contains(t *testing.T, jsonData []byte, jsonObject string, msgAndArgs ...interface{})
- func Empty(t *testing.T, jsonData []byte, msgAndArgs ...interface{})
- func Len(t *testing.T, jsonData []byte, expectedLen int, msgAndArgs ...interface{})
- func NotContains(t *testing.T, jsonData []byte, jsonObject string, msgAndArgs ...interface{})
- func NotEmpty(t *testing.T, jsonData []byte, msgAndArgs ...interface{})
- func Query(t *testing.T, jsonData []byte, jqQuery string, jsonExpected string, ...)
- type JQObject
- func (obj *JQObject) ArrayMustContain(jsonElement string, msgAndArgs ...interface{})
- func (obj *JQObject) IsFalse(msgAndArgs ...interface{})
- func (obj *JQObject) IsTrue(msgAndArgs ...interface{})
- func (obj *JQObject) LengthMustEqualTo(expectedLen int, msgAndArgs ...interface{})
- func (obj *JQObject) MustBeEmpty(msgAndArgs ...interface{})
- func (obj *JQObject) MustContain(jsonExpected string, msgAndArgs ...interface{})
- func (obj *JQObject) MustEqual(jsonExpected string, msgAndArgs ...interface{})
- func (obj *JQObject) MustNotBeEmpty(msgAndArgs ...interface{})
- func (obj *JQObject) MustNotContain(jsonExpected string, msgAndArgs ...interface{})
- func (obj *JQObject) Query(jqQuery string) *JQObject
- func (obj *JQObject) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains check if the json object is a subset of the jsonData. If the output doesn't match the test fails. If msgAndArgs are provided they will be used to explain the error.
func Empty ¶
Empty check if the size of the json object is zero. If the lenght is not zero the test fails. If msgAndArgs are provided they will be used to explain the error.
func Len ¶
Len check if the size of the json object match the given value. If the lenght doesn't match the test fails. If msgAndArgs are provided they will be used to explain the error.
func NotContains ¶
NotContains check if the json object is NOT a subset of the jsonData. If the output match the test fails. If msgAndArgs are provided they will be used to explain the error.
func NotEmpty ¶
NotEmpty check if the size of the json object is not zero. If the lenght is zero the test fails. If msgAndArgs are provided they will be used to explain the error.
func Query ¶
func Query(t *testing.T, jsonData []byte, jqQuery string, jsonExpected string, msgAndArgs ...interface{})
Query performs a test on a given json output. A jq-like query is performed on the given jsonData and the result is compared with jsonExpected. If the output doesn't match the test fails. If msgAndArgs are provided they will be used to explain the error.
Types ¶
type JQObject ¶ added in v1.1.0
type JQObject struct {
// contains filtered or unexported fields
}
JQObject is an object that abstract operations on JSON data.
func Parse ¶ added in v1.1.0
Parse creates a new JQObect from the given jsonData. If jsonData is not a valid json the test fails.
func ParseFromFile ¶ added in v1.3.0
ParseFromFile creates a new JQObect from the given file path. If the file is not a valid json the test fails.
func (*JQObject) ArrayMustContain ¶ added in v1.2.0
ArrayMustContain checks if the give JQObject contains the given element.
func (*JQObject) IsFalse ¶ added in v1.2.0
func (obj *JQObject) IsFalse(msgAndArgs ...interface{})
IsFalse test if the JQObject is `false`.
func (*JQObject) IsTrue ¶ added in v1.2.0
func (obj *JQObject) IsTrue(msgAndArgs ...interface{})
IsTrue test if the JQObject is `true`.
func (*JQObject) LengthMustEqualTo ¶ added in v1.1.0
LengthMustEqualTo tests if the size of JQObject match expectedLen. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.
func (*JQObject) MustBeEmpty ¶ added in v1.1.0
func (obj *JQObject) MustBeEmpty(msgAndArgs ...interface{})
MustBeEmpty test if the size of JQObject is 0. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.
func (*JQObject) MustContain ¶ added in v1.1.0
MustContain tests if jsonExpected is a subset of the JQObject. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.
func (*JQObject) MustEqual ¶ added in v1.1.0
MustEqual tests if the JQObject equals jsonExpected. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.
func (*JQObject) MustNotBeEmpty ¶ added in v1.1.0
func (obj *JQObject) MustNotBeEmpty(msgAndArgs ...interface{})
MustNotBeEmpty test if the size of JQObject is not 0. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.
func (*JQObject) MustNotContain ¶ added in v1.1.0
MustNotContain tests if the JQObject does not contain jsonExpected. If the check is not successful the test will fail. If msgAndArgs are provided they will be used to explain the error.