(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func 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 | }) |
nothing calls this directly
no test coverage detected