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

Function TestObject_ContainsValue

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

Source from the content-addressed store, hash-verified

769}
770
771func TestObject_ContainsValue(t *testing.T) {
772 t.Run("basic", func(t *testing.T) {
773 testObj := map[string]interface{}{"foo": 123, "bar": "xxx"}
774
775 cases := []struct {
776 name string
777 object map[string]interface{}
778 value interface{}
779 wantContainsKey chainResult
780 wantNotContainsKey chainResult
781 }{
782 {
783 name: "123 value, correct value",
784 object: testObj,
785 value: 123,
786 wantContainsKey: success,
787 wantNotContainsKey: failure,
788 },
789 {
790 name: "xxx value, correct value",
791 object: testObj,
792 value: "xxx",
793 wantContainsKey: success,
794 wantNotContainsKey: failure,
795 },
796 {
797 name: "XXX value, wrong value",
798 object: testObj,
799 value: "XXX",
800 wantContainsKey: failure,
801 wantNotContainsKey: success,
802 },
803 }
804
805 for _, tc := range cases {
806 t.Run(tc.name, func(t *testing.T) {
807 reporter := newMockReporter(t)
808
809 NewObject(reporter, tc.object).ContainsValue(tc.value).
810 chain.assert(t, tc.wantContainsKey)
811
812 NewObject(reporter, tc.object).NotContainsValue(tc.value).
813 chain.assert(t, tc.wantNotContainsKey)
814 })
815 }
816 })
817
818 t.Run("struct", func(t *testing.T) {
819 testObj := map[string]interface{}{
820 "foo": 123,
821 "bar": []interface{}{"456", 789},
822 "baz": map[string]interface{}{
823 "a": map[string]interface{}{
824 "b": 333,
825 "c": 444,
826 },
827 },
828 }

Callers

nothing calls this directly

Calls 6

newMockReporterFunction · 0.85
NewObjectFunction · 0.85
assertMethod · 0.80
ContainsValueMethod · 0.80
NotContainsValueMethod · 0.80
myIntTypeAlias · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…