Skip to content

Commit

Permalink
Converted to mod, using jsonpb to marshal stub responses and fixed te…
Browse files Browse the repository at this point in the history
…sts (tokopedia#62)

* Converted to mod and migrated from packr2 to pkger

* fix for well_known_types test failure and updated protoc plugin lib

* Use jsonpb to marshal stub into output proto message

* Added one-of to integration tests

Co-authored-by: Michael Eller <michael.eller@rakuten.com>
  • Loading branch information
HairyMike and Michael Eller committed Feb 15, 2021
1 parent 9315ff9 commit b162329
Show file tree
Hide file tree
Showing 12 changed files with 697 additions and 97 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ jobs:
uses: ./
with:
entrypoint: example/multi-files/entrypoint.sh

- name: Run one-of Example
uses: ./
with:
entrypoint: example/one-of/entrypoint.sh
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
vendor
Gopkg.lock
go.sum
pkged.go
gripmock
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ RUN go get -u -v github.com/golang/protobuf/protoc-gen-go \
github.com/lithammer/fuzzysearch/fuzzy \
golang.org/x/tools/imports

RUN go get -u -v github.com/gobuffalo/packr/v2/... \
github.com/gobuffalo/packr/v2/packr2
RUN go get github.com/markbates/pkger/cmd/pkger

# cloning well-known-types
RUN git clone https://github.com/google/protobuf.git /protobuf-repo
Expand All @@ -33,13 +32,11 @@ COPY . /go/src/github.com/tokopedia/gripmock

WORKDIR /go/src/github.com/tokopedia/gripmock/protoc-gen-gripmock

RUN packr2
RUN pkger

# install generator plugin
RUN go install -v

RUN packr2 clean

WORKDIR /go/src/github.com/tokopedia/gripmock

# install gripmock
Expand Down
58 changes: 0 additions & 58 deletions Gopkg.toml

This file was deleted.

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

0 comments on commit b162329

Please sign in to comment.