This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new c83a814 fix various linter warnings
new b847637 Merge pull request #624 from
cch123/fix-config-center-linter-warnings
c83a814 is described below
commit c83a814aaa45e22767e30c5b19c2b30fb483f9f9
Author: Xargin <[email protected]>
AuthorDate: Tue Jun 23 10:52:20 2020 +0800
fix various linter warnings
---
config_center/apollo/impl_test.go | 10 ++--
config_center/configurator/override.go | 66 ++++++++++++-----------
config_center/configurator/override_test.go | 37 +++++++------
config_center/mock_dynamic_config.go | 15 ++++--
config_center/nacos/client_test.go | 6 +--
config_center/nacos/impl_test.go | 12 ++---
config_center/nacos/listener.go | 2 +-
config_center/parser/configuration_parser_test.go | 6 +--
config_center/zookeeper/impl_test.go | 41 +++++++-------
9 files changed, 108 insertions(+), 87 deletions(-)
diff --git a/config_center/apollo/impl_test.go
b/config_center/apollo/impl_test.go
index a95524b..335fb71 100644
--- a/config_center/apollo/impl_test.go
+++ b/config_center/apollo/impl_test.go
@@ -125,7 +125,7 @@ func initApollo() *httptest.Server {
return runMockConfigServer(handlerMap, notifyResponse)
}
-func configResponse(rw http.ResponseWriter, req *http.Request) {
+func configResponse(rw http.ResponseWriter, _ *http.Request) {
result := fmt.Sprintf(mockConfigRes)
fmt.Fprintf(rw, "%s", result)
}
@@ -135,7 +135,7 @@ func notifyResponse(rw http.ResponseWriter, req
*http.Request) {
fmt.Fprintf(rw, "%s", result)
}
-func serviceConfigResponse(rw http.ResponseWriter, req *http.Request) {
+func serviceConfigResponse(rw http.ResponseWriter, _ *http.Request) {
result := fmt.Sprintf(mockServiceConfigRes)
fmt.Fprintf(rw, "%s", result)
}
@@ -164,7 +164,7 @@ func runMockConfigServer(handlerMap
map[string]func(http.ResponseWriter, *http.R
return ts
}
-func Test_GetConfig(t *testing.T) {
+func TestGetConfig(t *testing.T) {
configuration := initMockApollo(t)
configs, err := configuration.GetProperties(mockNamespace,
config_center.WithGroup("dubbo"))
assert.NoError(t, err)
@@ -175,7 +175,7 @@ func Test_GetConfig(t *testing.T) {
deleteMockJson(t)
}
-func Test_GetConfigItem(t *testing.T) {
+func TestGetConfigItem(t *testing.T) {
configuration := initMockApollo(t)
configs, err :=
configuration.GetInternalProperty("application.organization")
assert.NoError(t, err)
@@ -238,7 +238,7 @@ func TestRemoveListener(t *testing.T) {
apollo.RemoveListener(mockNamespace, listener)
assert.Equal(t, "", listener.event)
listenerCount := 0
- apollo.listeners.Range(func(key, value interface{}) bool {
+ apollo.listeners.Range(func(_, value interface{}) bool {
apolloListener := value.(*apolloListener)
for e := range apolloListener.listeners {
fmt.Println(e)
diff --git a/config_center/configurator/override.go
b/config_center/configurator/override.go
index ebd3dc6..294a60e 100644
--- a/config_center/configurator/override.go
+++ b/config_center/configurator/override.go
@@ -72,42 +72,46 @@ func (c *overrideConfigurator) Configure(url *common.URL) {
}
}
+func (c *overrideConfigurator) configureIfMatchInternal(url *common.URL) {
+ configApp := c.configuratorUrl.GetParam(constant.APPLICATION_KEY,
c.configuratorUrl.Username)
+ currentApp := url.GetParam(constant.APPLICATION_KEY, url.Username)
+ if len(configApp) == 0 || constant.ANY_VALUE == configApp || configApp
== currentApp {
+ conditionKeys := gxset.NewSet()
+ conditionKeys.Add(constant.CATEGORY_KEY)
+ conditionKeys.Add(constant.CHECK_KEY)
+ conditionKeys.Add(constant.ENABLED_KEY)
+ conditionKeys.Add(constant.GROUP_KEY)
+ conditionKeys.Add(constant.VERSION_KEY)
+ conditionKeys.Add(constant.APPLICATION_KEY)
+ conditionKeys.Add(constant.SIDE_KEY)
+ conditionKeys.Add(constant.CONFIG_VERSION_KEY)
+ conditionKeys.Add(constant.COMPATIBLE_CONFIG_KEY)
+ returnUrl := false
+ c.configuratorUrl.RangeParams(func(k, _ string) bool {
+ value := c.configuratorUrl.GetParam(k, "")
+ if strings.HasPrefix(k, "~") || k ==
constant.APPLICATION_KEY || k == constant.SIDE_KEY {
+ conditionKeys.Add(k)
+ if len(value) != 0 && value !=
constant.ANY_VALUE && value != url.GetParam(strings.TrimPrefix(k, "~"), "") {
+ returnUrl = true
+ return false
+ }
+ }
+ return true
+ })
+ if returnUrl {
+ return
+ }
+ configUrl := c.configuratorUrl.CloneExceptParams(conditionKeys)
+ url.SetParams(configUrl.GetParams())
+ }
+}
+
// configureIfMatch translate from java, compatible rules in java
func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) {
if constant.ANYHOST_VALUE == c.configuratorUrl.Ip || host ==
c.configuratorUrl.Ip {
providers :=
c.configuratorUrl.GetParam(constant.OVERRIDE_PROVIDERS_KEY, "")
if len(providers) == 0 || strings.Index(providers,
url.Location) >= 0 || strings.Index(providers, constant.ANYHOST_VALUE) >= 0 {
- configApp :=
c.configuratorUrl.GetParam(constant.APPLICATION_KEY, c.configuratorUrl.Username)
- currentApp := url.GetParam(constant.APPLICATION_KEY,
url.Username)
- if len(configApp) == 0 || constant.ANY_VALUE ==
configApp || configApp == currentApp {
- conditionKeys := gxset.NewSet()
- conditionKeys.Add(constant.CATEGORY_KEY)
- conditionKeys.Add(constant.CHECK_KEY)
- conditionKeys.Add(constant.ENABLED_KEY)
- conditionKeys.Add(constant.GROUP_KEY)
- conditionKeys.Add(constant.VERSION_KEY)
- conditionKeys.Add(constant.APPLICATION_KEY)
- conditionKeys.Add(constant.SIDE_KEY)
- conditionKeys.Add(constant.CONFIG_VERSION_KEY)
-
conditionKeys.Add(constant.COMPATIBLE_CONFIG_KEY)
- returnUrl := false
- c.configuratorUrl.RangeParams(func(k, v string)
bool {
- value := c.configuratorUrl.GetParam(k,
"")
- if strings.HasPrefix(k, "~") || k ==
constant.APPLICATION_KEY || k == constant.SIDE_KEY {
- conditionKeys.Add(k)
- if len(value) != 0 && value !=
constant.ANY_VALUE && value != url.GetParam(strings.TrimPrefix(k, "~"), "") {
- returnUrl = true
- return false
- }
- }
- return true
- })
- if returnUrl {
- return
- }
- configUrl :=
c.configuratorUrl.CloneExceptParams(conditionKeys)
- url.SetParams(configUrl.GetParams())
- }
+ c.configureIfMatchInternal(url)
}
}
}
diff --git a/config_center/configurator/override_test.go
b/config_center/configurator/override_test.go
index c0aeb15..8eccb50 100644
--- a/config_center/configurator/override_test.go
+++ b/config_center/configurator/override_test.go
@@ -30,51 +30,58 @@ import (
"github.com/apache/dubbo-go/common/extension"
)
-func Test_configureVerison2p6(t *testing.T) {
+const (
+ defaults = "default"
+ override = "override"
+ failfast = "failfast"
+ failover = "failover"
+)
+
+func TestConfigureVerison2p6(t *testing.T) {
url, err :=
common.NewURL("override://0.0.0.0:0/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService")
assert.NoError(t, err)
- configurator := extension.GetConfigurator("default", &url)
- assert.Equal(t, "override", configurator.GetUrl().Protocol)
+ configurator := extension.GetConfigurator(defaults, &url)
+ assert.Equal(t, override, configurator.GetUrl().Protocol)
providerUrl, err :=
common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&app.version=0.0.1&application=BDTService&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&group=&interface=com.ikurento.user.UserProvider&ip=10.32.20.124&loadbalance=random&methods.GetUser.loadbalance=random&methods.GetUser.retries=1&methods.GetUser.weight=0&module=dubbogo+user-info+server&name=BDTService&organization=ikurento.com&owner=ZX&pid=642
[...]
assert.NoError(t, err)
configurator.Configure(&providerUrl)
- assert.Equal(t, "failfast", providerUrl.GetParam(constant.CLUSTER_KEY,
""))
+ assert.Equal(t, failfast, providerUrl.GetParam(constant.CLUSTER_KEY,
""))
}
-func Test_configureVerisonOverrideAddr(t *testing.T) {
+func TestConfigureVerisonOverrideAddr(t *testing.T) {
url, err :=
common.NewURL("override://0.0.0.0:0/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService&providerAddresses=127.0.0.2:20001|127.0.0.3:20001")
assert.NoError(t, err)
- configurator := extension.GetConfigurator("default", &url)
- assert.Equal(t, "override", configurator.GetUrl().Protocol)
+ configurator := extension.GetConfigurator(defaults, &url)
+ assert.Equal(t, override, configurator.GetUrl().Protocol)
providerUrl, err :=
common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&app.version=0.0.1&application=BDTService&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&group=&interface=com.ikurento.user.UserProvider&ip=10.32.20.124&loadbalance=random&methods.GetUser.loadbalance=random&methods.GetUser.retries=1&methods.GetUser.weight=0&module=dubbogo+user-info+server&name=BDTService&organization=ikurento.com&owner=ZX&pid=642
[...]
assert.NoError(t, err)
configurator.Configure(&providerUrl)
- assert.Equal(t, "failover", providerUrl.GetParam(constant.CLUSTER_KEY,
""))
+ assert.Equal(t, failover, providerUrl.GetParam(constant.CLUSTER_KEY,
""))
}
-func Test_configureVerison2p6WithIp(t *testing.T) {
+func TestConfigureVerison2p6WithIp(t *testing.T) {
url, err :=
common.NewURL("override://127.0.0.1:20001/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService")
assert.NoError(t, err)
- configurator := extension.GetConfigurator("default", &url)
- assert.Equal(t, "override", configurator.GetUrl().Protocol)
+ configurator := extension.GetConfigurator(defaults, &url)
+ assert.Equal(t, override, configurator.GetUrl().Protocol)
providerUrl, err :=
common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&app.version=0.0.1&application=BDTService&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&group=&interface=com.ikurento.user.UserProvider&ip=10.32.20.124&loadbalance=random&methods.GetUser.loadbalance=random&methods.GetUser.retries=1&methods.GetUser.weight=0&module=dubbogo+user-info+server&name=BDTService&organization=ikurento.com&owner=ZX&pid=642
[...]
assert.NoError(t, err)
configurator.Configure(&providerUrl)
- assert.Equal(t, "failfast", providerUrl.GetParam(constant.CLUSTER_KEY,
""))
+ assert.Equal(t, failfast, providerUrl.GetParam(constant.CLUSTER_KEY,
""))
}
-func Test_configureVerison2p7(t *testing.T) {
+func TestConfigureVerison2p7(t *testing.T) {
url, err :=
common.NewURL("jsonrpc://0.0.0.0:20001/com.xxx.mock.userProvider?group=1&version=1&cluster=failfast&application=BDTService&configVersion=1.0&side=provider")
assert.NoError(t, err)
- configurator := extension.GetConfigurator("default", &url)
+ configurator := extension.GetConfigurator(defaults, &url)
providerUrl, err :=
common.NewURL("jsonrpc://127.0.0.1:20001/com.ikurento.user.UserProvider?anyhost=true&app.version=0.0.1&application=BDTService&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&group=&interface=com.ikurento.user.UserProvider&ip=10.32.20.124&loadbalance=random&methods.GetUser.loadbalance=random&methods.GetUser.retries=1&methods.GetUser.weight=0&module=dubbogo+user-info+server&name=BDTService&organization=ikurento.com&owner=ZX&pid=642
[...]
assert.NoError(t, err)
configurator.Configure(&providerUrl)
- assert.Equal(t, "failfast", providerUrl.GetParam(constant.CLUSTER_KEY,
""))
+ assert.Equal(t, failfast, providerUrl.GetParam(constant.CLUSTER_KEY,
""))
}
diff --git a/config_center/mock_dynamic_config.go
b/config_center/mock_dynamic_config.go
index 9cfb9e6..de20894 100644
--- a/config_center/mock_dynamic_config.go
+++ b/config_center/mock_dynamic_config.go
@@ -38,6 +38,10 @@ type MockDynamicConfigurationFactory struct {
Content string
}
+const (
+ mockServiceName = "org.apache.dubbo-go.mockService"
+)
+
var (
once sync.Once
dynamicConfiguration *MockDynamicConfiguration
@@ -106,6 +110,7 @@ func (c *MockDynamicConfiguration) AddListener(key string,
listener Configuratio
// RemoveListener removes the listener for MockDynamicConfiguration
func (c *MockDynamicConfiguration) RemoveListener(_ string, _
ConfigurationListener, _ ...Option) {
+ // mock remove
}
// GetConfig returns content of MockDynamicConfiguration
@@ -149,20 +154,20 @@ func (c *MockDynamicConfiguration)
MockServiceConfigEvent() {
config := &parser.ConfiguratorConfig{
ConfigVersion: "2.7.1",
Scope: parser.GeneralType,
- Key: "org.apache.dubbo-go.mockService",
+ Key: mockServiceName,
Enabled: true,
Configs: []parser.ConfigItem{
{Type: parser.GeneralType,
Enabled: true,
Addresses: []string{"0.0.0.0"},
- Services:
[]string{"org.apache.dubbo-go.mockService"},
+ Services: []string{mockServiceName},
Side: "provider",
Parameters: map[string]string{"cluster":
"mock1"},
},
},
}
value, _ := yaml.Marshal(config)
- key := "group*org.apache.dubbo-go.mockService:1.0.0" +
constant.CONFIGURATORS_SUFFIX
+ key := "group*" + mockServiceName + ":1.0.0" +
constant.CONFIGURATORS_SUFFIX
c.listener[key].Process(&ConfigChangeEvent{Key: key, Value:
string(value), ConfigType: remoting.EventTypeAdd})
}
@@ -171,13 +176,13 @@ func (c *MockDynamicConfiguration)
MockApplicationConfigEvent() {
config := &parser.ConfiguratorConfig{
ConfigVersion: "2.7.1",
Scope: parser.ScopeApplication,
- Key: "org.apache.dubbo-go.mockService",
+ Key: mockServiceName,
Enabled: true,
Configs: []parser.ConfigItem{
{Type: parser.ScopeApplication,
Enabled: true,
Addresses: []string{"0.0.0.0"},
- Services:
[]string{"org.apache.dubbo-go.mockService"},
+ Services: []string{mockServiceName},
Side: "provider",
Parameters: map[string]string{"cluster":
"mock1"},
},
diff --git a/config_center/nacos/client_test.go
b/config_center/nacos/client_test.go
index 53ab325..2e7f464 100644
--- a/config_center/nacos/client_test.go
+++ b/config_center/nacos/client_test.go
@@ -31,7 +31,7 @@ import (
"github.com/apache/dubbo-go/common"
)
-func Test_newNacosClient(t *testing.T) {
+func TestNewNacosClient(t *testing.T) {
server := mockCommonNacosServer()
nacosURL := strings.ReplaceAll(server.URL, "http", "registry")
registryUrl, _ := common.NewURL(nacosURL)
@@ -54,7 +54,7 @@ func Test_newNacosClient(t *testing.T) {
c.Destroy()
}
-func Test_setNacosClient(t *testing.T) {
+func TestSetNacosClient(t *testing.T) {
server := mockCommonNacosServer()
nacosURL := server.Listener.Addr().String()
registryUrl, _ := common.NewURL(nacosURL)
@@ -88,7 +88,7 @@ func Test_setNacosClient(t *testing.T) {
c.Destroy()
}
-func Test_newNacosClient_connectError(t *testing.T) {
+func TestNewNacosClient_connectError(t *testing.T) {
nacosURL := "registry://127.0.0.1:8888"
registryUrl, err := common.NewURL(nacosURL)
assert.NoError(t, err)
diff --git a/config_center/nacos/impl_test.go b/config_center/nacos/impl_test.go
index ebaad1c..453fa11 100644
--- a/config_center/nacos/impl_test.go
+++ b/config_center/nacos/impl_test.go
@@ -59,10 +59,10 @@ func runMockConfigServer(configHandler
func(http.ResponseWriter, *http.Request),
}
func mockCommonNacosServer() *httptest.Server {
- return runMockConfigServer(func(writer http.ResponseWriter, request
*http.Request) {
+ return runMockConfigServer(func(writer http.ResponseWriter, _
*http.Request) {
data := "true"
fmt.Fprintf(writer, "%s", data)
- }, func(writer http.ResponseWriter, request *http.Request) {
+ }, func(writer http.ResponseWriter, _ *http.Request) {
data :=
`dubbo.properties%02dubbo%02dubbo.service.com.ikurento.user.UserProvider.cluster=failback`
fmt.Fprintf(writer, "%s", data)
})
@@ -81,7 +81,7 @@ func initNacosData(t *testing.T) (*nacosDynamicConfiguration,
error) {
return nacosConfiguration.(*nacosDynamicConfiguration), err
}
-func Test_GetConfig(t *testing.T) {
+func TestGetConfig(t *testing.T) {
nacos, err := initNacosData(t)
assert.NoError(t, err)
configs, err := nacos.GetProperties("dubbo.properties",
config_center.WithGroup("dubbo"))
@@ -89,7 +89,7 @@ func Test_GetConfig(t *testing.T) {
assert.NoError(t, err)
}
-func TestNacosDynamicConfiguration_PublishConfig(t *testing.T) {
+func TestNacosDynamicConfigurationPublishConfig(t *testing.T) {
nacos, err := initNacosData(t)
assert.Nil(t, err)
key := "myKey"
@@ -99,7 +99,7 @@ func TestNacosDynamicConfiguration_PublishConfig(t
*testing.T) {
assert.Nil(t, err)
}
-func Test_AddListener(t *testing.T) {
+func TestAddListener(t *testing.T) {
nacos, err := initNacosData(t)
assert.NoError(t, err)
listener := &mockDataListener{}
@@ -109,7 +109,7 @@ func Test_AddListener(t *testing.T) {
listener.wg.Wait()
}
-func Test_RemoveListener(t *testing.T) {
+func TestRemoveListener(_ *testing.T) {
//TODO not supported in current go_nacos_sdk version
}
diff --git a/config_center/nacos/listener.go b/config_center/nacos/listener.go
index de74cff..4c99538 100644
--- a/config_center/nacos/listener.go
+++ b/config_center/nacos/listener.go
@@ -31,7 +31,7 @@ import (
"github.com/apache/dubbo-go/remoting"
)
-func callback(listener config_center.ConfigurationListener, namespace, group,
dataId, data string) {
+func callback(listener config_center.ConfigurationListener, _, _, dataId, data
string) {
listener.Process(&config_center.ConfigChangeEvent{Key: dataId, Value:
data, ConfigType: remoting.EventTypeUpdate})
}
diff --git a/config_center/parser/configuration_parser_test.go
b/config_center/parser/configuration_parser_test.go
index 3ba10f7..be2d45b 100644
--- a/config_center/parser/configuration_parser_test.go
+++ b/config_center/parser/configuration_parser_test.go
@@ -25,7 +25,7 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestDefaultConfigurationParser_Parser(t *testing.T) {
+func TestDefaultConfigurationParserParser(t *testing.T) {
parser := &DefaultConfigurationParser{}
m, err :=
parser.Parse("dubbo.registry.address=172.0.0.1\ndubbo.registry.name=test")
assert.NoError(t, err)
@@ -33,7 +33,7 @@ func TestDefaultConfigurationParser_Parser(t *testing.T) {
assert.Equal(t, "172.0.0.1", m["dubbo.registry.address"])
}
-func TestDefaultConfigurationParser_appItemToUrls_ParserToUrls(t *testing.T) {
+func TestDefaultConfigurationParserAppItemToUrls_ParserToUrls(t *testing.T) {
parser := &DefaultConfigurationParser{}
content := `configVersion: 2.7.1
scope: application
@@ -60,7 +60,7 @@ configs:
assert.Equal(t, "0.0.0.0", urls[0].Location)
}
-func TestDefaultConfigurationParser_serviceItemToUrls_ParserToUrls(t
*testing.T) {
+func TestDefaultConfigurationParserServiceItemToUrls_ParserToUrls(t
*testing.T) {
parser := &DefaultConfigurationParser{}
content := `configVersion: 2.7.1
scope: notApplication
diff --git a/config_center/zookeeper/impl_test.go
b/config_center/zookeeper/impl_test.go
index cfeba07..ecc3527 100644
--- a/config_center/zookeeper/impl_test.go
+++ b/config_center/zookeeper/impl_test.go
@@ -18,6 +18,7 @@ package zookeeper
import (
"fmt"
+ "path"
"strconv"
"sync"
"testing"
@@ -36,6 +37,10 @@ import (
"github.com/apache/dubbo-go/config_center/parser"
)
+const (
+ dubboPropertyFileName = "dubbo.properties"
+)
+
func initZkData(group string, t *testing.T) (*zk.TestCluster,
*zookeeperDynamicConfiguration) {
ts, err := zk.StartTestCluster(1, nil, nil)
assert.NoError(t, err)
@@ -76,43 +81,43 @@ func initZkData(group string, t *testing.T)
(*zk.TestCluster, *zookeeperDynamicC
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
if group != "" {
- err = zreg.client.Create(zreg.rootPath +
"/dubbo/dubbo.properties")
+ err = zreg.client.Create(path.Join(zreg.rootPath, "dubbo",
dubboPropertyFileName))
assert.NoError(t, err)
- _, err =
zreg.client.Conn.Set(zreg.rootPath+"/dubbo/dubbo.properties", []byte(data), 0)
+ _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, "dubbo",
dubboPropertyFileName), []byte(data), 0)
assert.NoError(t, err)
} else {
- err = zreg.client.Create(zreg.rootPath + "/dubbo.properties")
+ err = zreg.client.Create(path.Join(zreg.rootPath,
dubboPropertyFileName))
assert.NoError(t, err)
- _, err =
zreg.client.Conn.Set(zreg.rootPath+"/dubbo.properties", []byte(data), 0)
+ _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath,
dubboPropertyFileName), []byte(data), 0)
assert.NoError(t, err)
}
return ts, zreg
}
-func Test_GetConfig(t *testing.T) {
+func TestGetConfig(t *testing.T) {
ts, reg := initZkData("dubbo", t)
defer ts.Stop()
- configs, err := reg.GetProperties("dubbo.properties",
config_center.WithGroup("dubbo"))
+ configs, err := reg.GetProperties(dubboPropertyFileName,
config_center.WithGroup("dubbo"))
assert.NoError(t, err)
m, err := reg.Parser().Parse(configs)
assert.NoError(t, err)
assert.Equal(t, "5s", m["dubbo.consumer.request_timeout"])
- configs, err = reg.GetProperties("dubbo.properties")
+ configs, err = reg.GetProperties(dubboPropertyFileName)
assert.Error(t, err)
- configs, err = reg.GetInternalProperty("dubbo.properties")
+ configs, err = reg.GetInternalProperty(dubboPropertyFileName)
assert.Error(t, err)
- configs, err = reg.GetRule("dubbo.properties")
+ configs, err = reg.GetRule(dubboPropertyFileName)
assert.Error(t, err)
}
-func Test_AddListener(t *testing.T) {
+func TestAddListener(t *testing.T) {
ts, reg := initZkData("", t)
defer ts.Stop()
listener := &mockDataListener{}
- reg.AddListener("dubbo.properties", listener)
+ reg.AddListener(dubboPropertyFileName, listener)
listener.wg.Add(1)
data := `
dubbo.consumer.request_timeout=3s
@@ -135,17 +140,17 @@ func Test_AddListener(t *testing.T) {
dubbo.service.com.ikurento.user.UserProvider.warmup=100
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
- _, err := reg.client.Conn.Set(reg.rootPath+"/dubbo.properties",
[]byte(data), 1)
+ _, err := reg.client.Conn.Set(path.Join(reg.rootPath,
dubboPropertyFileName), []byte(data), 1)
assert.NoError(t, err)
listener.wg.Wait()
- assert.Equal(t, "dubbo.properties", listener.event)
+ assert.Equal(t, dubboPropertyFileName, listener.event)
}
-func Test_RemoveListener(t *testing.T) {
+func TestRemoveListener(t *testing.T) {
ts, reg := initZkData("", t)
defer ts.Stop()
listener := &mockDataListener{}
- reg.AddListener("dubbo.properties", listener)
+ reg.AddListener(dubboPropertyFileName, listener)
listener.wg.Add(1)
data := `
dubbo.consumer.request_timeout=3s
@@ -168,15 +173,15 @@ func Test_RemoveListener(t *testing.T) {
dubbo.service.com.ikurento.user.UserProvider.warmup=100
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
- reg.RemoveListener("dubbo.properties", listener)
+ reg.RemoveListener(dubboPropertyFileName, listener)
listener.wg.Done()
- _, err := reg.client.Conn.Set(reg.rootPath+"/dubbo.properties",
[]byte(data), 1)
+ _, err := reg.client.Conn.Set(path.Join(reg.rootPath,
dubboPropertyFileName), []byte(data), 1)
assert.NoError(t, err)
listener.wg.Wait()
assert.Equal(t, "", listener.event)
}
-func TestZookeeperDynamicConfiguration_PublishConfig(t *testing.T) {
+func TestZookeeperDynamicConfigurationPublishConfig(t *testing.T) {
value := "Test Data"
customGroup := "Custom Group"
key := "myKey"