-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Let's add some tests on a message that contains proto3 optional fields. As I did not want to affect the compilation of all the test protocol buffers with the --experimental_allow_proto3_optional flag, compile the one .proto file intended to test this path separately. Once the feature is no longer experimental (and behind a flag), this .proto can be compiled along with the other test fixtures. Add a TODO on the single test that will be updated when we add support for proto3 optional fields in the next commit.
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
|
||
package com.example; | ||
|
||
/** | ||
* Represents a cookie. | ||
*/ | ||
message Cookie { | ||
string id = 1; // The id of the cookie. | ||
optional string name = 2; // The name of the cookie. | ||
repeated string ingredients = 3; // Ingredients in the cookie. | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
package fixtures | ||
|
||
//go:generate protoc --descriptor_set_out=fileset.pb --include_imports --include_source_info -I. -I../thirdparty Booking.proto Vehicle.proto | ||
|
||
// Compiling proto3 optional fields requires using protoc >=3.12.x and passing the --experimental_allow_proto3_optional flag. | ||
// Rather than use this flag to compile all of the protocol buffers (which would eliminate test coverage for descriptors | ||
// compiled without the flag), only pass this flag when compiling the one message explicitly testing proto3 optional fields. | ||
// Once this feature is no longer behind an experimental flag, compilation of Cookie.proto can be moved to the above protoc command. | ||
//go:generate protoc --experimental_allow_proto3_optional --descriptor_set_out=cookie.pb --include_imports --include_source_info -I. -I../thirdparty Cookie.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters