Skip to content

Commit

Permalink
ange variable name; add more asserts for etcd_report tes
Browse files Browse the repository at this point in the history
  • Loading branch information
yexiaobo committed Jun 3, 2021
1 parent a030216 commit d9f0361
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions metadata/report/etcd/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ type etcdMetadataReport struct {
// GetAppMetadata get metadata info from etcd
func (e *etcdMetadataReport) GetAppMetadata(metadataIdentifier *identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) {
key := e.getNodeKey(metadataIdentifier)
_data, err := e.client.Get(key)
data, err := e.client.Get(key)
if err != nil {
return nil, err
}
info := &common.MetadataInfo{}
err = json.Unmarshal([]byte(_data), info)
err = json.Unmarshal([]byte(data), info)
if err != nil {
return nil, err
}
Expand Down
11 changes: 9 additions & 2 deletions metadata/report/etcd/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,21 @@ func TestEtcdMetadataReport_CRUD(t *testing.T) {
err = metadataReport.SaveSubscribedData(subMi, string(urls))
assert.Nil(t, err)

metadataInfo := common.NewMetadataInfWithApp(subMi.Application)
serviceUrl, _ = common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=&version=2.6.0")
metadataInfo := common.NewMetadataInfo(subMi.Application, "", map[string]*common.ServiceInfo{
"com.ikurento.user.UserProvider": common.NewServiceInfoWithURL(serviceUrl),
})
err = metadataReport.RemoveServiceMetadata(serviceMi)
assert.Nil(t, err)
err = metadataReport.PublishAppMetadata(subMi, metadataInfo)
assert.Nil(t, err)

_, err = metadataReport.GetAppMetadata(subMi)
mdInfo, err := metadataReport.GetAppMetadata(subMi)
assert.Nil(t, err)
assert.Equal(t, metadataInfo.App, mdInfo.App)
assert.Equal(t, metadataInfo.Revision, mdInfo.Revision)
assert.Equal(t, 1, len(mdInfo.Services))
assert.NotNil(t, metadataInfo.Services["com.ikurento.user.UserProvider"])

e.Close()
}
Expand Down

0 comments on commit d9f0361

Please sign in to comment.