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

No match data when field type is not string #96

Open
get109en opened this issue Sep 25, 2021 · 4 comments
Open

No match data when field type is not string #96

get109en opened this issue Sep 25, 2021 · 4 comments

Comments

@get109en
Copy link

If the field's type is string, everything goes well. But for a field whose type is not string, data can't be matched.
example:
------- pfoto file -------
// The Gripmock service definition.
service Gripmock {
// simple unary method
rpc SayHello (Request) returns (Reply);
}

// The request message containing the user's name.
message Request {
google.protobuf.StringValue name = 1;
}

// The response message containing the greetings
message Reply {
string message = 1;
int32 return_code = 2;
}

with stub
curl -X POST -d '{"service":"Greeter","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add
though below command can run well.
curl -X POST -d '{"service":"Greeter","method":"SayHello",{"data":{"name":"gripmock"}}}' localhost:4771/find

But when I tried grpcrul command like
grpcurl -plaintext -d @ localhost:4770 helloworld.Greeter/SayHello
{"name":"gripmock"}
^Z

Below error occurred.
ERROR:
Code: Unknow
Message: Can't find stub

Service: SayHello
Input
{
name: map[value:gripmock]
}
Closest Match
equals:{
name: gripmock
}

It seems other types except string type, map[value is added to input. Thus data can't be matched.
How to fix it?I tried to send the request by BloomRPC, the same error ocurred.

@1chickin
Copy link

1chickin commented Sep 27, 2021

Input format is defined in stub. You can read for solution here

p/s: Please edit request with style code.
double ` or
double ```

@get109en
Copy link
Author

Input format is defined in stub. You can read for solution here

p/s: Please edit request with style code. double ` or double ```

Sorry, I can't find solution in above link https://github.com/tokopedia/gripmock. Can't you tell me in details?
is google.protobuf.StringValue supported?

@1chickin
Copy link

1chickin commented Oct 3, 2021

Sorry for late! You can show me the docker command line that you use? and all steps, file stub you defined, command lines you run... please detail.

@get109en
Copy link
Author

get109en commented Oct 9, 2021

Sorry for late! You can show me the docker command line that you use? and all steps, file stub you defined, command lines you run... please detail.

Sorry for late. Let me give you some details.
Protofile just like below. It uses google.protobuf.StringValue .

syntax = "proto3";

package simple;

option go_package = "github.com/tokopedia/gripmock/example/simple";

// The Gripmock service definition.
service Gripmock {
// simple unary method
rpc SayHello (Request) returns (Reply);
}

// The request message containing the user's name.
message Request {
google.protobuf.StringValue name = 1;
}

// The response message containing the greetings
message Reply {
string message = 1;
int32 return_code = 2;
}

Then I mock the proto file.
docker run -p 4770:4770 -p 4771:4771 -v /mypath:/proto tkpd/gripmock /proto/hello.proto
And added stub by using below command.
curl -X POST -d '{"service":"Greeter","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' localhost:4771/add

But when I tried grpcrul command like
grpcurl -plaintext -d @ localhost:4770 helloworld.Greeter/SayHello
{"name":"gripmock"}
^Z

Below error occurred.
ERROR:
Code: Unknow
Message: Can't find stub

Service: SayHello
Input
{
name: map[value:gripmock]
}
Closest Match
equals:{
name: gripmock
}

@get109en get109en closed this as completed Oct 9, 2021
@get109en get109en reopened this Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants