(t *testing.T)
| 56 | } |
| 57 | |
| 58 | func 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 | |
| 92 | func TestProtoc(t *testing.T) { |
| 93 | const code = testdata.UnaryRPCsProtoCode |
nothing calls this directly
no test coverage detected