-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #358 from bavix/strict-method-mode
[3.x] lower method name
- Loading branch information
Showing
13 changed files
with
684 additions
and
32 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
This file was deleted.
Oops, something went wrong.
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
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,52 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
"time" | ||
|
||
grpcinterceptors "github.com/gripmock/grpc-interceptors" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
|
||
strictmode "github.com/bavix/gripmock/protogen/example/strictmode" | ||
) | ||
|
||
//nolint:mnd | ||
func main() { | ||
// Set up a connection to the server. | ||
conn, err := grpc.NewClient("localhost:4770", | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
grpc.WithChainUnaryInterceptor(grpcinterceptors.UnaryTimeoutInterceptor(5*time.Second)), | ||
grpc.WithChainStreamInterceptor(grpcinterceptors.StreamTimeoutInterceptor(5*time.Second))) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
|
||
c := strictmode.NewGripMockClient(conn) | ||
|
||
// Contact the server and print out its response. | ||
name := "GripMock Request" | ||
if len(os.Args) > 1 { | ||
name = os.Args[1] | ||
} | ||
r1, err := c.SayLowerHello(context.Background(), &strictmode.SayLowerHelloRequest{Name: name}, grpc.WaitForReady(true)) | ||
if err != nil { | ||
log.Fatalf("error from grpc: %v", err) | ||
} | ||
|
||
if r1.GetMessage() != "ok" { | ||
log.Fatalf("message is not ok: %s", r1.GetMessage()) | ||
} | ||
|
||
r2, err := c.SayTitleHello(context.Background(), &strictmode.SayTitleHelloRequest{Name: name}, grpc.WaitForReady(true)) | ||
if err != nil { | ||
log.Fatalf("error from grpc: %v", err) | ||
} | ||
|
||
if r2.GetMessage() != "OK" { | ||
log.Fatalf("message is not ok: %s", r2.GetMessage()) | ||
} | ||
} |
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 @@ | ||
#!/usr/bin/env sh | ||
|
||
# this file is used by .github/workflows/integration-test.yml | ||
|
||
STRICT_METHOD_TITLE=false gripmock \ | ||
--stub=example/strictmode/stub \ | ||
example/strictmode/method.proto & | ||
|
||
# wait for generated files to be available and gripmock is up | ||
gripmock check --silent --timeout=30s | ||
|
||
go run example/strictmode/client/*.go |
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,24 @@ | ||
syntax = "proto3"; | ||
|
||
package strictmode; | ||
|
||
service GripMock { | ||
rpc SayTitleHello (SayTitleHelloRequest) returns (SayTitleHelloReply); | ||
rpc sayLowerHello (sayLowerHelloRequest) returns (sayLowerHelloReply); | ||
} | ||
|
||
message sayLowerHelloRequest { | ||
string name = 1; | ||
} | ||
|
||
message sayLowerHelloReply { | ||
string message = 1; | ||
} | ||
|
||
message SayTitleHelloRequest { | ||
string name = 1; | ||
} | ||
|
||
message SayTitleHelloReply { | ||
string message = 1; | ||
} |
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,9 @@ | ||
service: GripMock | ||
method: sayLowerHello | ||
input: | ||
ignoreArrayOrder: true | ||
equals: | ||
name: "GripMock Request" | ||
output: | ||
data: | ||
message: "ok" |
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,9 @@ | ||
service: GripMock | ||
method: SayTitleHello | ||
input: | ||
ignoreArrayOrder: true | ||
equals: | ||
name: "GripMock Request" | ||
output: | ||
data: | ||
message: "OK" |
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
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
Oops, something went wrong.