(t *testing.T)
| 769 | } |
| 770 | |
| 771 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…