-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgrpc_test.go
82 lines (61 loc) · 1.75 KB
/
grpc_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package service
import (
"testing"
"google.golang.org/grpc"
"github.com/stevepartridge/service/middleware"
)
func Test_Unit_NewGrpcServer_Success(t *testing.T) {
svc, err := New(testPort1)
if err != nil {
t.Errorf("Service should not result in error %s", err.Error())
}
if svc == nil {
t.Error("service should not be nil")
}
server := svc.GrpcServer()
if server == nil {
t.Error("Grpc Server should not be nil")
}
}
func Test_Unit_NewGrpcServerAddUnaryInterceptor_Success(t *testing.T) {
svc, err := New(testPort1)
if err != nil {
t.Errorf("Service should not result in error %s", err.Error())
}
if svc == nil {
t.Error("service should not be nil")
}
svc.Grpc.AddUnaryInterceptors(middleware.RequestInterceptor())
if len(svc.Grpc.UnaryInterceptors) != 1 {
t.Errorf("Expected 1 but saw %d", len(svc.Grpc.UnaryInterceptors))
}
}
func Test_Unit_NewGrpcServerAddOption_Success(t *testing.T) {
svc, err := New(testPort1)
if err != nil {
t.Errorf("Service should not result in error %s", err.Error())
}
if svc == nil {
t.Error("service should not be nil")
}
svc.Grpc.AddOptions(grpc.MaxRecvMsgSize(1024))
if len(svc.Grpc.ServerOptions) != 1 {
t.Errorf("Expected 1 but saw %d", len(svc.Grpc.ServerOptions))
}
}
// func Test_Unit_ServiceNewEnableHandler_Success(t *testing.T) {
// svc, err := New(testPort1)
// if err != nil {
// t.Errorf("Service should not result in error %s", err.Error())
// }
// if svc == nil {
// t.Error("service should not be nil")
// }
// err = svc.EnableGatewayHandler(dummyGatewayHandler)
// if err != nil {
// t.Errorf("Error should be nil not %s", err.Error())
// }
// }
// func dummyGatewayHandler(context.Context, *runtime.ServeMux, string, []grpc.DialOption) error {
// return nil
// }