forked from JIUYEKEJI/gorpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
option_test.go
104 lines (91 loc) · 2.86 KB
/
option_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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package gorpc
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestWithAddress(t *testing.T) {
var serverops ServerOptions
fServerops := WithAddress("127.0.0.1")
fServerops(&serverops)
assert.Equal(t, "127.0.0.1", serverops.address)
fServerops = WithAddress("")
fServerops(&serverops)
assert.Equal(t, "", serverops.address)
}
func TestWithNetwork(t *testing.T) {
var serverops ServerOptions
fServerops := WithNetwork("test")
fServerops(&serverops)
assert.Equal(t, "test", serverops.network)
fServerops = WithNetwork("")
fServerops(&serverops)
assert.Equal(t, "", serverops.network)
}
func TestWithProtocol(t *testing.T) {
var serverops ServerOptions
fServerops := WithProtocol("http")
fServerops(&serverops)
assert.Equal(t, "http", serverops.protocol)
fServerops = WithProtocol("")
fServerops(&serverops)
assert.Equal(t, "", serverops.protocol)
}
func TestWithTimeout(t *testing.T) {
var serverops ServerOptions
fServerops := WithTimeout(time.Second * time.Duration(2))
fServerops(&serverops)
assert.Equal(t, time.Second*time.Duration(2), serverops.timeout)
}
func TestWithSerializationType(t *testing.T) {
var serverops ServerOptions
fServerops := WithSerializationType("test")
fServerops(&serverops)
assert.Equal(t, "test", serverops.serializationType)
fServerops = WithSerializationType("")
fServerops(&serverops)
assert.Equal(t, "", serverops.serializationType)
}
func TestWithSelectorSvrAddr(t *testing.T) {
var serverops ServerOptions
fServerops := WithSelectorSvrAddr("127.0.0.1")
fServerops(&serverops)
assert.Equal(t, "127.0.0.1", serverops.selectorSvrAddr)
fServerops = WithSelectorSvrAddr("")
fServerops(&serverops)
assert.Equal(t, "", serverops.selectorSvrAddr)
}
func TestWithPlugin(t *testing.T) {
var serverops ServerOptions
fServerops := WithPlugin("test")
fServerops(&serverops)
assert.Equal(t, []string{"test"}, serverops.pluginNames)
serverops.pluginNames=[]string(nil)
fServerops = WithPlugin("test","another_test")
fServerops(&serverops)
assert.Equal(t, []string{"test","another_test"}, serverops.pluginNames)
serverops.pluginNames=[]string(nil)
fServeropsNew := WithPlugin()
fServeropsNew(&serverops)
assert.Equal(t,[]string(nil), serverops.pluginNames)
}
func TestWithInterceptor(t *testing.T) {
}
func TestWithTracingSvrAddr(t *testing.T) {
var serverops ServerOptions
fServerops := WithTracingSvrAddr("127.0.0.1")
fServerops(&serverops)
assert.Equal(t, "127.0.0.1", serverops.tracingSvrAddr)
fServerops = WithTracingSvrAddr("")
fServerops(&serverops)
assert.Equal(t, "", serverops.tracingSvrAddr)
}
func TestWithTracingSpanName(t *testing.T) {
var serverops ServerOptions
fServerops := WithTracingSpanName("test")
fServerops(&serverops)
assert.Equal(t, "test", serverops.tracingSpanName)
fServerops = WithTracingSpanName("")
fServerops(&serverops)
assert.Equal(t, "", serverops.tracingSpanName)
}