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

add test case

parent f3260952
No related branches found
No related tags found
No related merge requests found
......@@ -39,9 +39,9 @@ func RouterInit(confRouterFile string) error {
if e == nil {
url := r.URL()
directory.AddRouterURLSet(&url)
break
return nil
}
logger.Warnf("router config type %s create fail \n", k)
}
return nil
return perrors.Errorf("no file router exists for parse %s , implement router.FIleRouterFactory please.", confRouterFile)
}
......@@ -18,6 +18,7 @@
package config
import (
"github.com/apache/dubbo-go/cluster/directory"
"strings"
"testing"
)
......@@ -26,7 +27,12 @@ import (
"github.com/stretchr/testify/assert"
)
const testyml = "testdata/router_config.yml"
import (
_ "github.com/apache/dubbo-go/cluster/router/condition"
)
const testYML = "testdata/router_config.yml"
const errorTestYML = "testdata/router_config_error.yml"
func TestString(t *testing.T) {
......@@ -47,3 +53,15 @@ func TestString(t *testing.T) {
assert.Equal(t, n2[0], "a1")
assert.Equal(t, n2[1], "")
}
func TestRouterInit(t *testing.T) {
errPro := RouterInit(errorTestYML)
assert.Error(t, errPro)
assert.Equal(t, 0, directory.GetRouterURLSet().Size())
errPro = RouterInit(testYML)
assert.NoError(t, errPro)
assert.Equal(t, 1, directory.GetRouterURLSet().Size())
}
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