MCPcopy Create free account
hub / github.com/gavv/httpexpect / TestObject_HasValue

Function TestObject_HasValue

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

Source from the content-addressed store, hash-verified

1195}
1196
1197func TestObject_HasValue(t *testing.T) {
1198 t.Run("basic", func(t *testing.T) {
1199 testObj := map[string]interface{}{
1200 "foo": 123,
1201 "bar": []interface{}{"456", 789},
1202 "baz": map[string]interface{}{
1203 "a": map[string]interface{}{
1204 "b": 333,
1205 "c": 444,
1206 },
1207 },
1208 }
1209
1210 cases := []struct {
1211 name string
1212 object map[string]interface{}
1213 key string
1214 value interface{}
1215 assertion uint
1216 wantContainsKey chainResult
1217 wantNotContainsKey chainResult
1218 }{
1219 {
1220 name: "correct key-value with primitives",
1221 object: testObj,
1222 key: "foo",
1223 value: 123,
1224 wantContainsKey: success,
1225 wantNotContainsKey: failure,
1226 },
1227 {
1228 name: "correct key-value with slices",
1229 object: testObj,
1230 key: "bar",
1231 value: []interface{}{"456", 789},
1232 wantContainsKey: success,
1233 wantNotContainsKey: failure,
1234 },
1235 {
1236 name: "wrong key-value with maps",
1237 object: testObj,
1238 key: "baz",
1239 value: map[string]interface{}{"a": "b"},
1240 wantContainsKey: failure,
1241 wantNotContainsKey: success,
1242 },
1243 {
1244 name: "wrong value with empty func",
1245 object: testObj,
1246 key: "baz",
1247 value: func() {},
1248 wantContainsKey: failure,
1249 wantNotContainsKey: failure,
1250 },
1251 {
1252 name: "wrong key-value with primitive",
1253 object: testObj,
1254 key: "BAZ",

Callers

nothing calls this directly

Calls 6

newMockReporterFunction · 0.85
NewObjectFunction · 0.85
assertMethod · 0.80
myIntTypeAlias · 0.70
HasValueMethod · 0.45
NotHasValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…