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

add case for this feature

parent 73e7bdd1
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@ func (c *ConfigCenterConfig) GetUrlMap() url.Values {
type configCenter struct {
}
// toURL will compatible with baseConfig.ConfigCenterConfig.Address before 1.6.0
// toURL will compatible with baseConfig.ConfigCenterConfig.Address and baseConfig.ConfigCenterConfig.RemoteRef before 1.6.0
// After 1.6.0 will not compatible, only baseConfig.ConfigCenterConfig.RemoteRef
func (b *configCenter) toURL(baseConfig BaseConfig) (common.URL, error) {
if len(baseConfig.ConfigCenterConfig.Address) > 0 {
......
......@@ -49,3 +49,48 @@ func TestStartConfigCenter(t *testing.T) {
assert.True(t, b)
assert.Equal(t, "ikurento.com", v)
}
func TestStartConfigCenterWithRemoteRef(t *testing.T) {
extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory {
return &config_center.MockDynamicConfigurationFactory{}
})
m := make(map[string]*RemoteConfig)
m["mock"] = &RemoteConfig{Address: "172.0.0.1"}
baseConfig = &BaseConfig{
Remotes: m,
ConfigCenterConfig: &ConfigCenterConfig{
Protocol: "mock",
Group: "dubbo",
RemoteRef: "mock",
ConfigFile: "mockDubbo.properties",
}}
c := &configCenter{}
err := c.startConfigCenter(*baseConfig)
assert.NoError(t, err)
b, v := config.GetEnvInstance().Configuration().Back().Value.(*config.InmemoryConfiguration).GetProperty("dubbo.application.organization")
assert.True(t, b)
assert.Equal(t, "ikurento.com", v)
baseConfig = nil
}
func TestStartConfigCenterWithRemoteRefError(t *testing.T) {
extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory {
return &config_center.MockDynamicConfigurationFactory{}
})
m := make(map[string]*RemoteConfig)
m["mock"] = &RemoteConfig{Address: "172.0.0.1"}
baseConfig := &BaseConfig{
Remotes: m,
ConfigCenterConfig: &ConfigCenterConfig{
Protocol: "mock",
Group: "dubbo",
RemoteRef: "mock",
ConfigFile: "mockDubbo.properties",
}}
c := &configCenter{}
err := c.startConfigCenter(*baseConfig)
assert.Error(t, err)
}
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