carvalhorr / protoc-gen-mock

47 stars 11 forks source link

Add a Client to the REST API #38

Closed carvalhorr closed 3 years ago

carvalhorr commented 3 years ago

Add a client to manage stubs without interacting with the REST API directly. The client will expose an interface to create stubs.

    m := greetservice.NewGreeterRemoteMockClient("127.0.0.1", 1068)
    md := metadata.Pairs("key1", "value1", "key2", "value2")
    ctx := metadata.NewOutgoingContext(context.Background(), md)
    m.OnHello(ctx, &greetservice.Request{Name: "Rodrigo"}).
        Return(&greetservice.Response{Greeting: "Hello, Rodrigo."})

    m.OnHello(ctx, &greetservice.Request{Name: "Carvalho"}).
        Error(codes.NotFound, "Not found")

    m.Clear()
carvalhorr commented 3 years ago

Thinking initially add only support to Add stubs and delete all stubs.

Limitations: