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

Function TestGetMetaTypeImports

codegen/import_test.go:13–172  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestGetMetaTypeImports(t *testing.T) {
14 testdata := []struct {
15 name string
16 dsl func()
17 want []string
18 }{
19 {
20 name: "payload-primitive",
21 dsl: func() {
22 dsl.Method("m", func() {
23 dsl.Payload(func() {
24 dsl.Attribute("a", dsl.String, func() {
25 dsl.Meta("struct:field:type", "CustomTypeString", "package/string")
26 })
27 dsl.Attribute("b", dsl.Int, func() {
28 dsl.Meta("struct:field:type", "CustomTypeInt", "package/int")
29 })
30 })
31 })
32 },
33 want: []string{
34 "package/string",
35 "package/int",
36 },
37 },
38 {
39 name: "payload-map",
40 dsl: func() {
41 dsl.Method("m", func() {
42 dsl.Payload(func() {
43 dsl.Attribute("a", dsl.MapOf(dsl.String, dsl.String, func() {
44 dsl.Key(func() {
45 dsl.Meta("struct:field:type", "CustomTypeMapKey", "package/map-key")
46 })
47 dsl.Elem(func() {
48 dsl.Meta("struct:field:type", "CustomTypeMapElem", "package/map-elem")
49 })
50 }))
51 })
52 })
53 },
54 want: []string{
55 "package/map-elem",
56 "package/map-key",
57 },
58 },
59 {
60 name: "payload-map-map",
61 dsl: func() {
62 dsl.Method("m", func() {
63 dsl.Payload(func() {
64 dsl.Attribute("a", dsl.MapOf(dsl.String, dsl.MapOf(dsl.String, dsl.String, func() {
65 dsl.Key(func() {
66 dsl.Meta("struct:field:type", "CustomTypeMapKey", "package/map-map-key")
67 })
68 dsl.Elem(func() {
69 dsl.Meta("struct:field:type", "CustomTypeMapElem", "package/map-map-elem")
70 })

Callers

nothing calls this directly

Calls 12

MethodFunction · 0.92
PayloadFunction · 0.92
AttributeFunction · 0.92
MetaFunction · 0.92
MapOfFunction · 0.92
KeyFunction · 0.92
ElemFunction · 0.92
ArrayOfFunction · 0.92
ResultFunction · 0.92
ExecuteFunction · 0.92
GetMetaTypeImportsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected