MCPcopy Create free account
hub / github.com/goadesign/goa / TestUnionGetValueKey

Function TestUnionGetValueKey

expr/types_test.go:911–941  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

909}
910
911func 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
943func TestUnionDupPreservesCustomKeys(t *testing.T) {
944 original := &Union{

Callers

nothing calls this directly

Calls 2

GetValueKeyMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected