-
Notifications
You must be signed in to change notification settings - Fork 157
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 #77 from niki290595/stub-subfolders
Stub subfolders support
- Loading branch information
Showing
7 changed files
with
410 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,37 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
pb "github.com/tokopedia/gripmock/example/stub-subfolders" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func main() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
|
||
// Set up a connection to the server. | ||
conn, err := grpc.DialContext(ctx, "localhost:4770", grpc.WithInsecure(), grpc.WithBlock()) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
|
||
c := pb.NewGripmockClient(conn) | ||
|
||
// Contact the server and print out its response. | ||
r, err := c.SayHello(context.Background(), &pb.Request{Name: "tokopedia"}) | ||
if err != nil { | ||
log.Fatalf("error from grpc: %v", err) | ||
} | ||
log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode) | ||
|
||
r, err = c.SayHello(context.Background(), &pb.Request{Name: "subtokopedia"}) | ||
if err != nil { | ||
log.Fatalf("error from grpc: %v", err) | ||
} | ||
log.Printf("Greeting: %s (return code %d)", r.Message, r.ReturnCode) | ||
} |
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,7 @@ | ||
#!/usr/bin/env sh | ||
|
||
# this file is used by .github/workflows/integration-test.yml | ||
|
||
gripmock --stub=example/stub-subfolders/stub example/stub-subfolders/stub-subfolders.proto & | ||
|
||
go run example/stub-subfolders/client/*.go |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
|
||
package stub_subfolders; | ||
|
||
// The Gripmock service definition. | ||
service Gripmock { | ||
// simple unary method | ||
rpc SayHello (Request) returns (Reply); | ||
} | ||
|
||
// The request message containing the user's name. | ||
message Request { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message Reply { | ||
string message = 1; | ||
int32 return_code = 2; | ||
} |
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,15 @@ | ||
{ | ||
"service": "Gripmock", | ||
"method": "SayHello", | ||
"input": { | ||
"equals": { | ||
"name": "tokopedia" | ||
} | ||
}, | ||
"output": { | ||
"data": { | ||
"message": "Hello Tokopedia", | ||
"return_code": 1 | ||
} | ||
} | ||
} |
Oops, something went wrong.