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

Converted to mod, using jsonpb to marshal stub responses and fixed tests #62

Merged
merged 4 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use jsonpb to marshal stub into output proto message
  • Loading branch information
Michael Eller committed Nov 12, 2020
commit 9fed149b5a70fb51119088f8b91f1654568ca094
39 changes: 39 additions & 0 deletions example/one-of/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"context"
"log"
"os"
"time"

oneof "github.com/tokopedia/gripmock/example/one-of"

"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 := oneof.NewGripmockClient(conn)

// Contact the server and print out its response.
name := "tokopedia"
if len(os.Args) > 1 {
name = os.Args[1]
}
r, err := c.SayHello(context.Background(), &oneof.Request{Name: name})
if err != nil {
log.Fatalf("error from grpc: %v", err)
}
log.Printf("Reply1: %s", r.GetReply1())
log.Printf("Reply2: %s", r.GetReply2())
log.Printf("ReplyType: %s", r.GetReplyType())
}
7 changes: 7 additions & 0 deletions example/one-of/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/one-of/stub example/one-of/oneof.proto &

go run example/one-of/client/*.go
Loading