MCPcopy Index your code
hub / github.com/gavv/httpexpect / TestObject_NotFind

Function TestObject_NotFind

object_test.go:2159–2251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2157}
2158
2159func TestObject_NotFind(t *testing.T) {
2160 t.Run("no match", func(t *testing.T) {
2161 reporter := newMockReporter(t)
2162 object := NewObject(reporter, map[string]interface{}{
2163 "foo": "bar",
2164 "baz": true,
2165 "qux": -1,
2166 "quux": 2,
2167 })
2168
2169 afterObject := object.NotFind(func(key string, value *Value) bool {
2170 return key == "corge"
2171 })
2172
2173 assert.Same(t, object, afterObject)
2174 object.chain.assert(t, success)
2175 })
2176
2177 t.Run("have match", func(t *testing.T) {
2178 reporter := newMockReporter(t)
2179 object := NewObject(reporter, map[string]interface{}{
2180 "foo": "bar",
2181 "baz": true,
2182 "qux": -1,
2183 "quux": 2,
2184 })
2185
2186 afterObject := object.NotFind(func(key string, value *Value) bool {
2187 return key == "qux"
2188 })
2189
2190 assert.Same(t, object, afterObject)
2191 object.chain.assert(t, failure)
2192 })
2193
2194 t.Run("empty object", func(t *testing.T) {
2195 reporter := newMockReporter(t)
2196 object := NewObject(reporter, map[string]interface{}{})
2197
2198 afterObject := object.NotFind(func(key string, value *Value) bool {
2199 return key == "corge"
2200 })
2201
2202 assert.Same(t, object, afterObject)
2203 object.chain.assert(t, success)
2204 })
2205
2206 t.Run("predicate returns true, assertion fails, no match", func(t *testing.T) {
2207 reporter := newMockReporter(t)
2208 object := NewObject(reporter, map[string]interface{}{
2209 "foo": 1,
2210 "bar": 2,
2211 })
2212
2213 afterObject := object.NotFind(func(key string, value *Value) bool {
2214 value.String()
2215 return true
2216 })

Callers

nothing calls this directly

Calls 5

NotFindMethod · 0.95
newMockReporterFunction · 0.85
NewObjectFunction · 0.85
assertMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…