Skip to content

Commit e0b0d84

Browse files
committed
fix(proto): add generated comment
Previously a file comment was used, which does not render with protoprint.
1 parent 6fd1d4e commit e0b0d84

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pkg/proto/proto.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ func APIToProto(a *api.API, outputDir string) (*desc.FileDescriptor, error) {
6666
fb := builder.NewFile("test.proto")
6767
fb.Package = packageName
6868
fb.IsProto3 = true
69-
fb.SetComments(builder.Comments{
70-
LeadingComment: "this file is autogenerated by aepc",
69+
// As a file comment is not printed by protoprint,
70+
// use package comments instead.
71+
fb.SetPackageComments(builder.Comments{
72+
LeadingComment: "this file is generated.",
7173
})
7274
pServiceName := toProtoServiceName(a.Name)
7375
serviceNameAsLower := fmt.Sprintf("/%s", strings.ToLower(pServiceName))

pkg/proto/proto_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func TestAPIToProto(t *testing.T) {
7979
// verify that ArchiveTome is a long-running-operation.
8080
"rpc ArchiveTome ( ArchiveTomeRequest ) returns ( aep.api.Operation ) {",
8181
"string id = 10014;",
82+
"this file is generated.",
8283
},
8384
},
8485
}
@@ -134,14 +135,14 @@ func TestAPIToProto(t *testing.T) {
134135
strings.Contains(strings.ToLower(protoContent), "rpc "+methodNameLower+"(") ||
135136
strings.Contains(protoContent, "rpc "+methodName+" (") ||
136137
strings.Contains(protoContent, "rpc "+methodName+"("),
137-
"Expected method %s not found in proto content", methodName)
138+
"Expected method %q not found in proto content", methodName)
138139
}
139140

140141
// Check for expected strings
141142
for _, expectedString := range tt.expectStrings {
142143
assert.True(t,
143144
strings.Contains(protoContent, expectedString),
144-
"Expected string %s not found in proto content", expectedString)
145+
"Expected string %q not found in proto content", expectedString)
145146
}
146147

147148
// Verify correct parent-child relationships in the API paths

0 commit comments

Comments
 (0)