Skip to content
Snippets Groups Projects
Commit e89ceb85 authored by vito.he's avatar vito.he
Browse files

Mod:roll back

parent e74d8ba3
No related branches found
No related tags found
No related merge requests found
......@@ -195,20 +195,20 @@ func GetApplicationConfig() *ApplicationConfig {
// GetProviderConfig find the provider config
// if not found, create new one
func GetProviderConfig() *ProviderConfig {
func GetProviderConfig() ProviderConfig {
if providerConfig == nil {
logger.Warnf("providerConfig is nil!")
return &ProviderConfig{}
return ProviderConfig{}
}
return providerConfig
return *providerConfig
}
// GetConsumerConfig find the consumer config
// if not found, create new one
func GetConsumerConfig() *ConsumerConfig {
func GetConsumerConfig() ConsumerConfig {
if consumerConfig == nil {
logger.Warnf("consumerConfig is nil!")
return &ConsumerConfig{}
return ConsumerConfig{}
}
return consumerConfig
return *consumerConfig
}
......@@ -43,9 +43,9 @@ func TestConfigLoader(t *testing.T) {
assert.NoError(t, err)
assert.Nil(t, consumerConfig)
assert.Equal(t, &ConsumerConfig{}, GetConsumerConfig())
assert.Equal(t, ConsumerConfig{}, GetConsumerConfig())
assert.Nil(t, providerConfig)
assert.Equal(t, &ProviderConfig{}, GetProviderConfig())
assert.Equal(t, ProviderConfig{}, GetProviderConfig())
err = ConsumerInit(conPath)
assert.NoError(t, err)
......@@ -53,9 +53,9 @@ func TestConfigLoader(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, consumerConfig)
assert.NotEqual(t, &ConsumerConfig{}, GetConsumerConfig())
assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig())
assert.NotNil(t, providerConfig)
assert.NotEqual(t, &ProviderConfig{}, GetProviderConfig())
assert.NotEqual(t, ProviderConfig{}, GetProviderConfig())
assert.Equal(t, "soa.com.ikurento.user.UserProvider", GetConsumerConfig().References["UserProvider"].Params["serviceid"])
}
......@@ -155,9 +155,9 @@ func TestConfigLoaderWithConfigCenter(t *testing.T) {
assert.NoError(t, err)
assert.Nil(t, consumerConfig)
assert.Equal(t, &ConsumerConfig{}, GetConsumerConfig())
assert.Equal(t, ConsumerConfig{}, GetConsumerConfig())
assert.Nil(t, providerConfig)
assert.Equal(t, &ProviderConfig{}, GetProviderConfig())
assert.Equal(t, ProviderConfig{}, GetProviderConfig())
err = ConsumerInit(conPath)
configCenterRefreshConsumer()
......@@ -167,9 +167,9 @@ func TestConfigLoaderWithConfigCenter(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, consumerConfig)
assert.NotEqual(t, &ConsumerConfig{}, GetConsumerConfig())
assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig())
assert.NotNil(t, providerConfig)
assert.NotEqual(t, &ProviderConfig{}, GetProviderConfig())
assert.NotEqual(t, ProviderConfig{}, GetProviderConfig())
assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name)
assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address)
......@@ -208,9 +208,9 @@ func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) {
assert.NoError(t, err)
assert.Nil(t, consumerConfig)
assert.Equal(t, &ConsumerConfig{}, GetConsumerConfig())
assert.Equal(t, ConsumerConfig{}, GetConsumerConfig())
assert.Nil(t, providerConfig)
assert.Equal(t, &ProviderConfig{}, GetProviderConfig())
assert.Equal(t, ProviderConfig{}, GetProviderConfig())
err = ConsumerInit(conPath)
checkApplicationName(consumerConfig.ApplicationConfig)
......@@ -224,9 +224,9 @@ func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, consumerConfig)
assert.NotEqual(t, &ConsumerConfig{}, GetConsumerConfig())
assert.NotEqual(t, ConsumerConfig{}, GetConsumerConfig())
assert.NotNil(t, providerConfig)
assert.NotEqual(t, &ProviderConfig{}, GetProviderConfig())
assert.NotEqual(t, ProviderConfig{}, GetProviderConfig())
assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name)
assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address)
......
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