Skip to content

Commit

Permalink
fix some get config bug
Browse files Browse the repository at this point in the history
  • Loading branch information
robynron committed Dec 13, 2023
1 parent 5449978 commit 97c9c22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions clients/config_client/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ func (client *ConfigClient) getConfigInner(param vo.ConfigParam) (content, encry
if response != nil && response.Response != nil && !response.IsSuccess() {
return response.Content, response.EncryptedDataKey, errors.New(response.GetMessage())
}
param.EncryptedDataKey = response.EncryptedDataKey
param.Content = response.Content
encryptedDataKey = response.EncryptedDataKey
content = response.Content
return content, encryptedDataKey, nil
}

Expand Down
4 changes: 2 additions & 2 deletions clients/config_client/config_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (m *MockConfigProxy) queryConfig(dataId, group, tenant string, timeout uint
if IsLimited(cacheKey) {
return nil, errors.New("request is limited")
}
return &rpc_response.ConfigQueryResponse{Content: "hello world"}, nil
return &rpc_response.ConfigQueryResponse{Content: "hello world", Response: &rpc_response.Response{Success: true}}, nil
}
func (m *MockConfigProxy) searchConfigProxy(param vo.SearchConfigParam, tenant, accessKey, secretKey string) (*model.ConfigPage, error) {
return &model.ConfigPage{TotalCount: 1}, nil
Expand All @@ -94,7 +94,7 @@ func Test_GetConfig(t *testing.T) {

content, err := client.GetConfig(vo.ConfigParam{
DataId: localConfigTest.DataId,
Group: "group"})
Group: localConfigTest.Group})

assert.Nil(t, err)
assert.Equal(t, "hello world", content)
Expand Down
17 changes: 5 additions & 12 deletions vo/config_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@ import (

func TestConfigParamDeepCopy(t *testing.T) {
param := &ConfigParam{
DataId: "dataId",
Group: "",
Content: "common content",
Tag: "",
AppName: "",
BetaIps: "",
CasMd5: "",
Type: "",
SrcUser: "",
EncryptedDataKey: "",
KmsKeyId: "",
UsageType: RequestType,
DataId: "dataId",
Group: "",
Content: "common content",
UsageType: RequestType,
OnChange: func(namespace, group, dataId, data string) {
//do nothing
},
Expand All @@ -43,5 +35,6 @@ func TestConfigParamDeepCopy(t *testing.T) {

assert.Equal(t, param.DataId, paramDeepCopied.DataId)
assert.Equal(t, param.Content, paramDeepCopied.Content)
assert.NotEqual(t, param.OnChange, paramDeepCopied.OnChange)
assert.NotEqual(t, &param, &paramDeepCopied)
}

0 comments on commit 97c9c22

Please sign in to comment.