加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
option_test.go 2.86 KB
一键复制 编辑 原始数据 按行查看 历史
xingyuping 提交于 2020-04-07 21:14 . fix(test):fix test to http
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)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化