-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpcrequest_test.go
48 lines (42 loc) · 1.18 KB
/
grpcrequest_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
package grpcrequest
import (
"context"
"testing"
"github.com/sirupsen/logrus"
)
func TestRequestNilContext(t *testing.T) {
Setup(logrus.StandardLogger(), nil, nil)
req := New(nil, map[string]interface{}{
"parameter": "param_value",
})
req.FinishOK()
req.FinishError("error: %s", "err")
req.FinishNotFound()
req.Finish("some_result", "got some result")
}
func TestRequestBaseContext(t *testing.T) {
Setup(logrus.StandardLogger(), nil, nil)
req := New(context.Background(), map[string]interface{}{
"parameter": "param_value",
})
req.FinishOK()
req.FinishError("error: %s", "err")
req.FinishNotFound()
req.Finish("some_result", "got some result")
}
func TestRequestNoAdditional(t *testing.T) {
Setup(logrus.StandardLogger(), nil, nil)
req := New(context.Background(), nil)
req.FinishOK()
req.FinishError("error: %s", "err")
req.FinishNotFound()
req.Finish("some_result", "got some result")
}
func TestRequestWithRequestID(t *testing.T) {
Setup(logrus.StandardLogger(), nil, nil)
req := NewWithRequestID(context.Background(), nil, "test_request_id")
req.FinishOK()
req.FinishError("error: %s", "err")
req.FinishNotFound()
req.Finish("some_result", "got some result")
}