Skip to content

Commit

Permalink
generator: fix extractServices slice index (#45)
Browse files Browse the repository at this point in the history
* generator: fix extractServices slice index

Signed-off-by: Guillaume Delbergue <[email protected]>

* multifiles test

Co-authored-by: Ahmad Muzakki <[email protected]>
  • Loading branch information
guyguy333 and jekiapp authored Aug 3, 2020
1 parent 398c134 commit 9315ff9
Show file tree
Hide file tree
Showing 10 changed files with 537 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ jobs:
uses: ./
with:
entrypoint: example/multi-package/entrypoint.sh
- name: Run Multi Files Example
uses: ./
with:
entrypoint: example/multi-files/entrypoint.sh

40 changes: 40 additions & 0 deletions example/multi-files/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"context"
"log"
"time"

pb "github.com/tokopedia/gripmock/example/multi-files"
"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.NewGripmock1Client(conn)

// Contact the server and print out its response.
r, err := c.SayHello(context.Background(), &pb.Request1{Name: "tokopedia"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
log.Printf("Greeting: %s", r.Message)

c2 := pb.NewGripmock2Client(conn)

// Contact the server and print out its response.
r2, err := c2.SayHello(context.Background(), &pb.Request2{Name: "tokopedia"})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
log.Printf("Greeting: %s", r2.Message)
}
7 changes: 7 additions & 0 deletions example/multi-files/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/multi-files/stub example/multi-files/file1.proto example/multi-files/file2.proto &

go run example/multi-files/client/*.go
206 changes: 206 additions & 0 deletions example/multi-files/file1.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/multi-files/file1.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package multifiles;

// The Gripmock service definition.
service Gripmock1 {
// simple unary method
rpc SayHello (Request1) returns (Reply1);
}

// The request message containing the user's name.
message Request1 {
string name = 1;
}

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

0 comments on commit 9315ff9

Please sign in to comment.