Skip to content

Commit

Permalink
Merge pull request #77 from niki290595/stub-subfolders
Browse files Browse the repository at this point in the history
Stub subfolders support
  • Loading branch information
jekiapp authored Jan 27, 2022
2 parents 4365b42 + af90f0d commit d43af75
Show file tree
Hide file tree
Showing 7 changed files with 410 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example/stub-subfolders/client/main.go
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)
}
7 changes: 7 additions & 0 deletions example/stub-subfolders/entrypoint.sh
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
311 changes: 311 additions & 0 deletions example/stub-subfolders/stub-subfolders.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions example/stub-subfolders/stub-subfolders.proto
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;
}
15 changes: 15 additions & 0 deletions example/stub-subfolders/stub/stub.json
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
}
}
}
Loading

0 comments on commit d43af75

Please sign in to comment.