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

Function TestUnionGetTypeKey

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

Source from the content-addressed store, hash-verified

877}
878
879func TestUnionGetTypeKey(t *testing.T) {
880 cases := map[string]struct {
881 typeKey string
882 expected string
883 }{
884 "default": {
885 typeKey: "",
886 expected: "type",
887 },
888 "custom": {
889 typeKey: "kind",
890 expected: "kind",
891 },
892 "discriminator": {
893 typeKey: "discriminator",
894 expected: "discriminator",
895 },
896 }
897
898 for name, tc := range cases {
899 t.Run(name, func(t *testing.T) {
900 union := &Union{
901 TypeName: "TestUnion",
902 TypeKey: tc.typeKey,
903 }
904 if actual := union.GetTypeKey(); actual != tc.expected {
905 t.Errorf("got %q, expected %q", actual, tc.expected)
906 }
907 })
908 }
909}
910
911func TestUnionGetValueKey(t *testing.T) {
912 cases := map[string]struct {

Callers

nothing calls this directly

Calls 2

GetTypeKeyMethod · 0.95
RunMethod · 0.45

Tested by

no test coverage detected