-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy paththriftclient_test.go
38 lines (33 loc) · 938 Bytes
/
thriftclient_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
package turbo
import (
"testing"
"github.com/apache/thrift/lib/go/thrift"
logger "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
)
func TestThriftInit(t *testing.T) {
defer func() {
if err := recover(); err != nil {
assert.Fail(t, "should not panic")
}
}()
s := &ThriftServer{tClient: new(thriftClient)}
s.tClient.thriftService = make(map[string]interface{})
s.tClient.init("", func(thrift.TTransport, thrift.TProtocolFactory) map[string]interface{} { return nil })
}
func TestThriftClose(t *testing.T) {
s := &ThriftServer{tClient: new(thriftClient)}
err := s.tClient.close()
assert.Nil(t, err)
}
func TestThriftService(t *testing.T) {
defer func() {
if err := recover(); err != nil {
assert.Equal(t, "thrift connection not initiated!", err.(*logger.Entry).Message)
} else {
t.Errorf("The code did not panic")
}
}()
s := &ThriftServer{tClient: new(thriftClient)}
s.Service("")
}