add more tests

This commit is contained in:
kevin
2020-08-22 23:08:33 +08:00
parent 59ba4ecc5b
commit b82c02ed16
5 changed files with 167 additions and 6 deletions

View File

@@ -14,9 +14,19 @@ func TestUnaryStatInterceptor(t *testing.T) {
interceptor := UnaryStatInterceptor(metrics)
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
FullMethod: "/",
}, func(
ctx context.Context, req interface{}) (interface{}, error) {
}, func(ctx context.Context, req interface{}) (interface{}, error) {
return nil, nil
})
assert.Nil(t, err)
}
func TestUnaryStatInterceptor_crash(t *testing.T) {
metrics := stat.NewMetrics("mock")
interceptor := UnaryStatInterceptor(metrics)
_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
FullMethod: "/",
}, func(ctx context.Context, req interface{}) (interface{}, error) {
panic("error")
})
assert.NotNil(t, err)
}