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

Function TestMessageDefSection

grpc/codegen/proto_test.go:58–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

56}
57
58func TestMessageDefSection(t *testing.T) {
59 cases := []struct {
60 Name string
61 DSL func()
62 }{
63 {"user-type-with-primitives", testdata.MessageUserTypeWithPrimitivesDSL},
64 {"user-type-with-alias", testdata.MessageUserTypeWithAliasMessageDSL},
65 {"user-type-with-nested-user-types", testdata.MessageUserTypeWithNestedUserTypesDSL},
66 {"result-type-collection", testdata.MessageResultTypeCollectionDSL},
67 {"user-type-with-collection", testdata.MessageUserTypeWithCollectionDSL},
68 {"array", testdata.MessageArrayDSL},
69 {"map", testdata.MessageMapDSL},
70 {"primitive", testdata.MessagePrimitiveDSL},
71 {"with-metadata", testdata.MessageWithMetadataDSL},
72 {"with-security-attributes", testdata.MessageWithSecurityAttrsDSL},
73 }
74 for _, c := range cases {
75 t.Run(c.Name, func(t *testing.T) {
76 root := RunGRPCDSL(t, c.DSL)
77 services := CreateGRPCServices(root)
78 fs := ProtoFiles("", services)
79 require.Len(t, fs, 1)
80 sections := fs[0].SectionTemplates
81 require.GreaterOrEqual(t, len(sections), 3)
82 code := sectionCode(t, sections[:2]...)
83 msgCode := sectionCode(t, sections[3:]...)
84 // testutil.AssertString handles line ending normalization internally
85 testutil.AssertString(t, "testdata/golden/proto_"+c.Name+".proto.golden", code+msgCode)
86 fpath := codegen.CreateTempFile(t, code+msgCode)
87 assert.NoError(t, protoc(defaultProtocCmd, fpath, nil), "error occurred when compiling proto file %q", fpath)
88 })
89 }
90}
91
92func TestProtoc(t *testing.T) {
93 const code = testdata.UnaryRPCsProtoCode

Callers

nothing calls this directly

Calls 8

AssertStringFunction · 0.92
CreateTempFileFunction · 0.92
RunGRPCDSLFunction · 0.85
CreateGRPCServicesFunction · 0.85
ProtoFilesFunction · 0.85
sectionCodeFunction · 0.85
protocFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected