Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find enum #333

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions examples/grpc/grpc_consumer_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//go:build consumer
// +build consumer

package grpc

import (
Expand Down Expand Up @@ -36,16 +33,16 @@ func TestGrpcInteraction(t *testing.T) {
"pact:proto": "` + path + `",
"pact:proto-service": "RouteGuide/GetFeature",
"pact:content-type": "application/protobuf",
"pact:protobuf-config": {
"additionalIncludes": ["` + dir + `/routeguide"]
},
"request": {
"latitude": "matching(number, 180)",
"longitude": "matching(number, 200)"
"stuff": {
"id": "foo"
}
},
"response": {
"name": "notEmpty('Big Tree')",
"location": {
"latitude": "matching(number, 180)",
"longitude": "matching(number, 200)"
}
"result_code": "RESULT_CODE_OK"
}
}`

Expand All @@ -68,11 +65,16 @@ func TestGrpcInteraction(t *testing.T) {
defer conn.Close()

// Create the gRPC client
c := routeguide.NewRouteGuideClient(conn)
c := routeguide_v2.NewRouteGuideClient(conn)

point := &routeguide.Point{
Latitude: 180,
Longitude: 200,
feature_id := &routeguide_v2.IdentitySpec_Id{
Id: "foo",
}
feature_spec := &routeguide_v2.IdentitySpec{
Identity: feature_id,
}
point := &routeguide_v2.FeatureRequest{
Stuff: feature_spec,
}

// Now we can make a normal gRPC request
Expand All @@ -84,9 +86,7 @@ func TestGrpcInteraction(t *testing.T) {
t.Fatal(err.Error())
}

feature.GetLocation()
assert.Equal(t, "Big Tree", feature.GetName())
assert.Equal(t, int32(180), feature.GetLocation().GetLatitude())
assert.Equal(t, routeguide_v2.ResultCode(1), feature.GetResultCode())

return nil
})
Expand Down
16 changes: 16 additions & 0 deletions examples/grpc/routeguide/getmore.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";

package routeguide.v2;

// import "common.proto";
// import "relators.proto";

option go_package = "routeguide/v2;routeguide_v2";

// identity specification
message IdentitySpec {
oneof identity {
string id = 1;
string name = 2;
}
}
23 changes: 20 additions & 3 deletions examples/grpc/routeguide/route_guide.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@

syntax = "proto3";

option go_package = "google.golang.org/grpc/examples/route_guide/routeguide";
import "getmore.proto";

option go_package = "routeguide/v2;routeguide_v2";
option java_multiple_files = true;
option java_package = "io.grpc.examples.routeguide";
option java_outer_classname = "RouteGuideProto";

package routeguide;
package routeguide.v2;

enum ResultCode {
RESULT_CODE_UNSPECIFIED = 0;
RESULT_CODE_OK = 1;
RESULT_CODE_UNKNOWN = 2;
}

// Interface exported by the server.
service RouteGuide {
Expand All @@ -29,7 +37,7 @@ service RouteGuide {
//
// A feature with an empty name is returned if there's no feature at the given
// position.
rpc GetFeature(Point) returns (Feature) {}
rpc GetFeature(FeatureRequest) returns (FeatureResponse) {}

// A server-to-client streaming RPC.
//
Expand All @@ -52,6 +60,15 @@ service RouteGuide {
rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
}

message FeatureRequest {
IdentitySpec stuff = 1;
}

message FeatureResponse {
ResultCode result_code = 1;
string stuff = 2;
}

// Points are represented as latitude-longitude pairs in the E7 representation
// (degrees multiplied by 10**7 and rounded to the nearest integer).
// Latitudes should be in the range +/- 90 degrees and longitude should be in
Expand Down