Skip to content

Commit

Permalink
Merge pull request #1118 from wenxuwan/fix_type_error
Browse files Browse the repository at this point in the history
add ut for config_loader file
  • Loading branch information
AlexStocks authored Mar 31, 2021
2 parents 759bea2 + e0c3fdb commit 78bea16
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions config/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,26 @@ func TestWithNoRegLoad(t *testing.T) {
providerConfig = nil
}

func TestSetDefaultValue(t *testing.T) {
proConfig := &ProviderConfig{Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig)}
assert.Nil(t, proConfig.ApplicationConfig)
setDefaultValue(proConfig)
assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s")
assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper")
assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo")
assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000")
assert.NotNil(t, proConfig.ApplicationConfig)

conConfig := &ConsumerConfig{Registries: make(map[string]*RegistryConfig)}
assert.Nil(t, conConfig.ApplicationConfig)
setDefaultValue(conConfig)
assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s")
assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper")
assert.NotNil(t, conConfig.ApplicationConfig)

}
func TestConfigLoaderWithConfigCenter(t *testing.T) {
extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory {
return &config_center.MockDynamicConfigurationFactory{}
Expand Down

0 comments on commit 78bea16

Please sign in to comment.