Skip to content
Snippets Groups Projects
Commit 6436e242 authored by 邹毅贤's avatar 邹毅贤
Browse files

add test case

parent b016f017
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ import (
"github.com/stretchr/testify/assert"
)
const testyml = "testdata/router_config.yml"
func TestString(t *testing.T) {
s := "a1=>a2"
......@@ -41,7 +43,7 @@ func TestString(t *testing.T) {
func TestLoadYmlConfig(t *testing.T) {
routerConfig = &ConditionRouterConfig{}
e := loadYmlConfig("testdata/router_config.yml", routerConfig)
e := loadYmlConfig(testyml, routerConfig)
assert.Nil(t, e)
assert.NotNil(t, routerConfig)
assert.Equal(t, routerConfig.RawRule, "kkk")
......@@ -71,3 +73,19 @@ func TestRouterInit(t *testing.T) {
assert.Equal(t, routerConfig.Key, "abc")
assert.Equal(t, len(routerConfig.Conditions), 2)
}
func TestParseCondition(t *testing.T) {
s := make([]string, 2)
s = append(s, "a => b")
s = append(s, "c => d")
condition := parseCondition(s)
assert.Equal(t, "a & c => b & d", condition)
}
func TestInitRouterUrl(t *testing.T) {
routerConfig = &ConditionRouterConfig{}
loadYmlConfig(testyml, routerConfig)
url := initRouterUrl()
assert.Equal(t, url.Protocol, "route")
assert.Equal(t, url.Ip, "0.0.0.0")
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment