Skip to content

Commit

Permalink
use go fmt to update the format
Browse files Browse the repository at this point in the history
  • Loading branch information
william feng committed Jun 27, 2020
1 parent 67a933b commit 2c940e6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
40 changes: 20 additions & 20 deletions config/base_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import (
_ "github.com/apache/dubbo-go/config_center/apollo"
)

func getMockMap() map[string]string{
func getMockMap() map[string]string {
baseMockMap := map[string]string{
"dubbo.registries.shanghai_reg1.protocol": "mock100",
"dubbo.registries.shanghai_reg1.protocol": "mock100",
"dubbo.reference.com.MockService.MockService.retries": "10",
"dubbo.com.MockService.MockService.GetUser.retries": "10",
"dubbo.consumer.check": "false",
"dubbo.application.name": "dubbo",
"dubbo.com.MockService.MockService.GetUser.retries": "10",
"dubbo.consumer.check": "false",
"dubbo.application.name": "dubbo",
}
return baseMockMap
}
Expand Down Expand Up @@ -116,10 +116,10 @@ func TestRefresh(t *testing.T) {
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)

father := &ConsumerConfig{
Check: &[]bool{true}[0],
Check: &[]bool{true}[0],
ApplicationConfig: baseAppConfig,
Registries: baseRegistries,
References: baseMockRef,
Registries: baseRegistries,
References: baseMockRef,
ShutdownConfig: &ShutdownConfig{
Timeout: "12s",
StepTimeout: "2s",
Expand Down Expand Up @@ -148,10 +148,10 @@ func TestAppExternalRefresh(t *testing.T) {
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
father := &ConsumerConfig{
Check: &[]bool{true}[0],
Check: &[]bool{true}[0],
ApplicationConfig: baseAppConfig,
Registries: baseRegistries,
References: baseMockRef,
Registries: baseRegistries,
References: baseMockRef,
}

c.SetFatherConfig(father)
Expand All @@ -174,10 +174,10 @@ func TestAppExternalWithoutIDRefresh(t *testing.T) {
mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
father := &ConsumerConfig{
Check: &[]bool{true}[0],
Check: &[]bool{true}[0],
ApplicationConfig: baseAppConfig,
Registries: baseRegistries,
References: baseMockRef,
Registries: baseRegistries,
References: baseMockRef,
}

c.SetFatherConfig(father)
Expand All @@ -202,11 +202,11 @@ func TestRefreshSingleRegistry(t *testing.T) {
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)

father := &ConsumerConfig{
Check: &[]bool{true}[0],
Check: &[]bool{true}[0],
ApplicationConfig: baseAppConfig,
Registries: map[string]*RegistryConfig{},
Registry: &RegistryConfig{},
References: baseMockRef,
Registries: map[string]*RegistryConfig{},
Registry: &RegistryConfig{},
References: baseMockRef,
}

c.SetFatherConfig(father)
Expand All @@ -232,7 +232,7 @@ func TestRefreshProvider(t *testing.T) {

father := &ProviderConfig{
ApplicationConfig: baseAppConfig,
Registries: baseRegistries,
Registries: baseRegistries,
Services: map[string]*ServiceConfig{
"MockService": {
InterfaceName: "com.MockService",
Expand All @@ -251,7 +251,7 @@ func TestRefreshProvider(t *testing.T) {
Loadbalance: "random",
},
{
InterfaceId: "MockService",
InterfaceId: "MockService",
InterfaceName: "com.MockService",
Name: "GetUser1",
Retries: "2",
Expand Down
6 changes: 3 additions & 3 deletions config/config_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func mergeValue(str1, str2, def string) string {
str = "," + constant.DEFAULT_KEY + str
}
str = strings.TrimPrefix(strings.Replace(str, ","+constant.DEFAULT_KEY, ","+def, -1), ",")
return removeMinus(strings.Split(str, ","))
return removeMinus(strings.Split(str, ","))
}

func removeMinus(strArr []string) string {
Expand All @@ -50,14 +50,14 @@ func removeMinus(strArr []string) string {
var minusStrArr []string
for _, v := range strArr {
if strings.HasPrefix(v, "-") {
minusStrArr = append(minusStrArr,v[1:])
minusStrArr = append(minusStrArr, v[1:])
} else {
normalStr += fmt.Sprintf(",%s", v)
}
}
normalStr = strings.Trim(normalStr, ",")
for _, v := range minusStrArr {
normalStr = strings.Replace(normalStr, v, "",1)
normalStr = strings.Replace(normalStr, v, "", 1)
}
reg := regexp.MustCompile("[,]+")
normalStr = reg.ReplaceAllString(strings.Trim(normalStr, ","), ",")
Expand Down
4 changes: 2 additions & 2 deletions config/config_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ func TestRemoveMinus(t *testing.T) {
strList = removeMinus([]string{"b", "a", "-c", "c"})
assert.Equal(t, strList, "b,a")

strList = removeMinus([]string{"c", "b", "a", "d","c", "-c", "-a", "e", "f"})
strList = removeMinus([]string{"c", "b", "a", "d", "c", "-c", "-a", "e", "f"})
assert.Equal(t, strList, "b,d,c,e,f")
}
}

0 comments on commit 2c940e6

Please sign in to comment.