(t *testing.T)
| 909 | } |
| 910 | |
| 911 | func TestUnionGetValueKey(t *testing.T) { |
| 912 | cases := map[string]struct { |
| 913 | valueKey string |
| 914 | expected string |
| 915 | }{ |
| 916 | "default": { |
| 917 | valueKey: "", |
| 918 | expected: "value", |
| 919 | }, |
| 920 | "custom": { |
| 921 | valueKey: "data", |
| 922 | expected: "data", |
| 923 | }, |
| 924 | "payload": { |
| 925 | valueKey: "payload", |
| 926 | expected: "payload", |
| 927 | }, |
| 928 | } |
| 929 | |
| 930 | for name, tc := range cases { |
| 931 | t.Run(name, func(t *testing.T) { |
| 932 | union := &Union{ |
| 933 | TypeName: "TestUnion", |
| 934 | ValueKey: tc.valueKey, |
| 935 | } |
| 936 | if actual := union.GetValueKey(); actual != tc.expected { |
| 937 | t.Errorf("got %q, expected %q", actual, tc.expected) |
| 938 | } |
| 939 | }) |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | func TestUnionDupPreservesCustomKeys(t *testing.T) { |
| 944 | original := &Union{ |
nothing calls this directly
no test coverage detected