File tree 2 files changed +17
-0
lines changed
2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,21 @@ func (obj *JQObject) MustNotBeEmpty(msgAndArgs ...interface{}) {
113
113
}
114
114
}
115
115
116
+ // IsTrue test if the JQObject is `true`.
117
+ func (obj * JQObject ) IsTrue (msgAndArgs ... interface {}) {
118
+ obj .MustEqual ("true" , msgAndArgs ... )
119
+ }
120
+
121
+ // IsFalse test if the JQObject is `false`.
122
+ func (obj * JQObject ) IsFalse (msgAndArgs ... interface {}) {
123
+ obj .MustEqual ("false" , msgAndArgs ... )
124
+ }
125
+
126
+ // ArrayMustContain checks if the give JQObject contains the given element.
127
+ func (obj * JQObject ) ArrayMustContain (jsonElement string , msgAndArgs ... interface {}) {
128
+ obj .Query (`any(. == ` + jsonElement + `)` ).IsTrue (msgAndArgs ... )
129
+ }
130
+
116
131
// Query performs a test on a given json output. A jq-like query is performed
117
132
// on the given jsonData and the result is compared with jsonExpected.
118
133
// If the output doesn't match the test fails. If msgAndArgs are provided they
Original file line number Diff line number Diff line change @@ -65,4 +65,6 @@ func TestJSONAssertions(t *testing.T) {
65
65
requirejson .Len (t , in3 , 3 )
66
66
67
67
requirejson .Query (t , in , ".list | length" , "3" )
68
+
69
+ requirejson .Parse (t , in ).Query (".list" ).ArrayMustContain ("20" )
68
70
}
You can’t perform that action at this time.
0 commit comments