-
Notifications
You must be signed in to change notification settings - Fork 3
/
engine_test.go
40 lines (37 loc) · 964 Bytes
/
engine_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package engine_test
import (
"context"
"fmt"
"github.com/autom8ter/engine"
"github.com/autom8ter/engine/config"
"github.com/autom8ter/engine/examples/examplepb"
"github.com/autom8ter/engine/examples/examplepb/client"
"github.com/autom8ter/util"
ex2 "github.com/grpc-ecosystem/grpc-gateway/examples/proto/examplepb"
"google.golang.org/grpc/grpclog"
"os"
"testing"
)
func init() {
if err := os.Setenv("DEBUG", "t"); err != nil {
grpclog.Fatalln(err.Error())
}
}
func TestGRPC(t *testing.T) {
var eng = engine.New("tcp", ":3002", true).With(
config.WithDefaultMiddlewares(),
config.WithDefaultPlugins(),
config.WithPlugins(examplepb.NewExample()),
)
go eng.Serve()
var grpcCli = client.ExampleClient(":3002")
resp, err := grpcCli.EchoBody(context.Background(), &ex2.SimpleMessage{
Id: "yoyoyoyoyo",
Num: 199,
})
if err != nil {
t.Fatal(err.Error())
}
fmt.Println("GRPC RESPONSE:")
fmt.Println(util.ToPrettyJsonString(resp))
}