Skip to content

Commit

Permalink
test: Add method/service comments to all test protos
Browse files Browse the repository at this point in the history
(Generated code is in the next commit.)
  • Loading branch information
jskeet committed Jun 27, 2024
1 parent e5aff7b commit 442998e
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Google.Api.Generator.Tests/ProtoTest.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

package testing;

// Test service
service Test {
// Test method
rpc Method(Msg) returns(Msg);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ option csharp_namespace = "Testing.BasicBidiStreaming";

import "google/api/client.proto";

// Test service
service BasicBidiStreaming {
option (google.api.default_host) = "bidi.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc MethodBidi(stream Request) returns(stream Response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import "google/api/client.proto";

option csharp_namespace = "Testing.BasicClientStreaming";

// Test service
service BasicClientStreaming {
option (google.api.default_host) = "clientstreaming.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc MethodClient(stream Request) returns (Response);
}

Expand Down
2 changes: 2 additions & 0 deletions Google.Api.Generator.Tests/ProtoTests/BasicLro/BasicLro.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ package testing.basiclro;

option csharp_namespace = "Testing.BasicLro";

// Test service
service BasicLro {
option (google.api.default_host) = "lro.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc Method1(Request) returns(google.longrunning.Operation) {
option (google.longrunning.operation_info) = {
response_type: "LroResponse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ option csharp_namespace = "Testing.BasicPaginated";

import "google/api/client.proto";

// Test service
service BasicPaginated {
option (google.api.default_host) = "paginated.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc MethodPaginated(Request) returns(Response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ option csharp_namespace = "Testing.BasicServerStreaming";

import "google/api/client.proto";

// Test service
service BasicServerStreaming {
option (google.api.default_host) = "serverstreaming.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc MethodServer(Request) returns(stream Response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ import "google/api/client.proto";
import "google/api/resource.proto";
import "google/api/field_behavior.proto";

// Test service
service ChildResource {
// Test method
rpc SingleParentMethod(SingleParent) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref";
}

// Test method
rpc WildcardParentMethod(WildcardParent) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref, ref_sugar, repeated_ref_sugar";
}

// Test method
rpc TripleParentMethod(TripleParent) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref";
}

// Test method
rpc TripleWildcardParentMethod(TripleWildcardParent) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref";
}

// Test method
rpc OverlapParentMethod(OverlapParent) returns(Response) {
option (google.api.method_signature) = "ref"; // "ref" and "repeated_ref" would generate too many overloads.
option (google.api.method_signature) = "repeated_ref";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ option csharp_namespace = "Testing.CommonResource";
import "google/api/client.proto";
import "google/api/resource.proto";

// Test serviceS
service CommonResource {
option (google.api.default_host) = "commonresource.example.com";

// Test method
rpc MethodWithCommonResource(Request) returns(Response) {
option (google.api.method_signature) = "project_name";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@ package testing.deprecated;

import "google/api/client.proto";

// Test service
service Deprecated {
option (google.api.default_host) = "deprecated.example.com";

// Test method
rpc DeprecatedFieldMethod(DeprecatedFieldRequest) returns(Response) {
option (google.api.method_signature) = "deprecated_field_1, deprecated_field_2";
};

// Test method
rpc DeprecatedMessageMethod(DeprecatedMessageRequest) returns(Response);

// Test method
rpc DeprecatedMethod(Request) returns(Response) {
option deprecated = true;
};

// Test method
rpc DeprecatedResponseMethod(Request) returns(DeprecatedMessageResponse);
}

Expand All @@ -26,9 +31,11 @@ service DeprecatedService {
option deprecated = true;
option (google.api.default_host) = "deprecated.example.com";

// Test method
rpc NonDeprecatedMethod(Request) returns(Response) {
};

// Test method
rpc DeprecatedMethod(Request) returns(Response) {
option deprecated = true;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ option (google.api.resource_definition) = {
pattern: "organizations/{organization}"
};

// Test service
service Basic {
option (google.api.default_host) = "basic.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc AMethod(Request) returns(Response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,30 @@ option csharp_namespace = "Testing.GrpcServiceConfig";

import "google/api/client.proto";

// Test service
service GrpcServiceConfigNoRetry {
option (google.api.default_host) = "grpcserviceconfig.example.com";

// Test method
rpc NoRetryMethod(Request) returns(Response);
}

// Test service
service GrpcServiceConfig {
option (google.api.default_host) = "grpcserviceconfig.example.com";

// Test method
rpc ServiceLevelRetryMethod(Request) returns(Response);

// Test method
rpc MethodLevelRetryMethod(Request) returns(Response);

// Test method
rpc MethodWithServerRetry(Request) returns(stream Response);
// Test method
rpc MethodWithBidiRetry(stream Request) returns(stream Response);

// Test method
rpc MethodTimeoutOnly(Request) returns(Response);
}

Expand Down
3 changes: 3 additions & 0 deletions Google.Api.Generator.Tests/ProtoTests/Keywords/Keywords.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ option csharp_namespace = "Testing.Keywords";
import "google/api/client.proto";
import "google/api/resource.proto";

// Test service
service Keywords {
// Test method
rpc Method1(Request) returns(Response) {
option (google.api.method_signature) = "event, switch, void, request, types";
}

// Test method
rpc Method2(Resource) returns(Response) {
option (google.api.method_signature) = "while, enum";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/wrappers.proto";

// Test service
service MethodSignatures {
option (google.api.default_host) = "methodsignatures.example.com";

// Test method
rpc SimpleMethod(SimpleRequest) returns(Response) {
option (google.api.method_signature) = ""; // Test zero-parameter signature. This would be unusual, but valid.
option (google.api.method_signature) = "a_number";
Expand All @@ -19,34 +21,42 @@ service MethodSignatures {
option (google.api.method_signature) = "a_string,a_number";
}

// Test method
rpc PrimitiveArgs(PrimitiveRequest) returns(Response) {
option (google.api.method_signature) = "optional,required,repeated_optional,repeated_required";
}

// Test method
rpc StringArgs(StringRequest) returns(Response) {
option (google.api.method_signature) = "optional,required,repeated_optional,repeated_required";
}

// Test method
rpc BytesArgs(BytesRequest) returns(Response) {
option (google.api.method_signature) = "optional,required,repeated_optional,repeated_required";
}

// Test method
rpc MessageArgs(MessageRequest) returns(Response) {
option (google.api.method_signature) = "optional,required,repeated_optional,repeated_required";
}

// Test method
rpc MapArgs(MapRequest) returns(Response) {
option (google.api.method_signature) = "optional, required";
}

// Test method
rpc EnumArgs(EnumRequest) returns(Response) {
option (google.api.method_signature) = "optional,required,repeated_optional,repeated_required,top_level_optional,top_level_required,repeated_top_level_optional,repeated_top_level_required";
}

// Test method
rpc NestedArgs(NestedRequest) returns(Response) {
option (google.api.method_signature) = "nest1.a_string,nest1.nest2.a_number,nest1.nest2.another_number,nest1.nest_outer.a_bool,top_level_string";
}

// Test method
rpc WktArgs(WktRequest) returns (Response) {
option (google.api.method_signature) = "optional_int32,required_int32,repeated_optional_int32,repeated_required_int32,optional_string,required_string,repeated_optional_string,repeated_required_string";
}
Expand Down
2 changes: 2 additions & 0 deletions Google.Api.Generator.Tests/ProtoTests/Mixins/Mixins.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ option csharp_namespace = "Testing.Mixins";

import "google/api/client.proto";

// Test service
service MixinService {
option (google.api.default_host) = "mixins.example.com";
option (google.api.oauth_scopes) = "scope1,scope2";

// Test method
rpc Method(Request) returns(Response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ option csharp_namespace = "Testing.OptionalFields";
import "google/api/client.proto";
import "google/api/resource.proto";

// Test service
service OptionalFields {
// Test method
rpc Method1(Request) returns(Response) {
option (google.api.method_signature) = "name,number";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package testing.paginated;
import "google/api/client.proto";
import "google/api/resource.proto";

// Test service
service Paginated {
option (google.api.default_host) = "paginated.example.com";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,22 @@ service ServiceWithResources {

// This is a service with method settings in the service config.
service ServiceWithMethodSettings {
// Test method
rpc UnaryAutoPopulated(Request) returns (Response);
// Test method
rpc ServerStreamingAutoPopulated(Request) returns (stream Response);
// Test method
rpc ClientStreamingAutoPopulated(stream Request) returns (Response);
// Test method
rpc BidiStreamingAutoPopulated(stream Request) returns (stream Response);
// Test method
rpc LroAutoPopulated(Request) returns (google.longrunning.Operation) {
option (google.longrunning.operation_info) = {
response_type: "Response"
metadata_type: "Response"
};
}
// Test method
rpc PaginatedAutoPopulated(PaginatedRequest) returns (PaginatedResponse);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import "google/api/resource.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/wrappers.proto";

// Test service
service ResourceNameSeparator {
// Test method
rpc Method1(Request) returns(Response) {
option (google.api.method_signature) = "name, ref";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,34 @@ import "google/api/resource.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/wrappers.proto";

// Test service
service ResourceNames {
// Test method
rpc SinglePatternMethod(SinglePattern) returns(Response) {
option (google.api.method_signature) = "real_name, ref, repeated_ref, value_ref, repeated_value_ref";
}

// Test method
rpc DeprecatedPatternMethod(DeprecatedPattern) returns(Response) {
option (google.api.method_signature) = "name";
}

// Test method
rpc WildcardOnlyPatternMethod(WildcardOnlyPattern) returns(Response) {
option (google.api.method_signature) = "name, ref, repeated_ref, ref_sugar, repeated_ref_sugar";
}

// Test method
rpc WildcardMultiPatternMethod(WildcardMultiPattern) returns(Response) {
option (google.api.method_signature) = "name, ref, repeated_ref";
}

// Test method
rpc WildcardMultiPatternMultipleMethod(WildcardMultiPatternMultiple) returns(Response) {
option (google.api.method_signature) = "ref, repeated_ref"; // `name` parameter delibrately missing.
}

// Test method
rpc LooseValidationPatternMethod(LooseValidationPattern) returns(Response) {
option (google.api.method_signature) = "name";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,31 @@ option csharp_namespace = "Testing.RoutingHeaders";
import "google/api/annotations.proto";
import "google/api/client.proto";

// Test service
service RoutingHeaders {
option (google.api.default_host) = "routingheaders.example.com";

// Test method
rpc NoUrlMethod(SimpleRequest) returns(Response);
// Test method
rpc GetMethod(SimpleRequest) returns(Response) { option (google.api.http).get = "{name=items/*}/child"; };
// Test method
rpc PostMethod(SimpleRequest) returns(Response) { option (google.api.http).post = "{name=items/*}/child"; };
// Test method
rpc PutMethod(SimpleRequest) returns(Response) { option (google.api.http).put = "{name=items/*}/child"; };
// Test method
rpc PatchMethod(SimpleRequest) returns(Response) { option (google.api.http).patch = "{name=items/*}/child"; };
// Test method
rpc DeleteMethod(SimpleRequest) returns(Response) { option (google.api.http).delete = "{name=items/*}/child"; };
// Test method
rpc GetNoTemplateMethod(SimpleRequest) returns(Response) { option (google.api.http).get = "{name}/child"; };

// Test method
rpc NestedMultiMethod(NestedRequest) returns(Response) {
option (google.api.http).get = "{nest1.nest2.name=items/*}/child1/{name=items/*}/child2";
};

// Test method
rpc ServerStreamingMethod(SimpleRequest) returns (stream Response) { option (google.api.http).post = "{name=items/*}/child"; };
}

Expand Down
Loading

0 comments on commit 442998e

Please sign in to comment.