Added zrpc server custom serverID for custom registration Key when the service is registered on ETCD. (#3008)

This commit is contained in:
Shyunn
2023-03-11 14:34:28 +08:00
committed by GitHub
parent 4cef2b412c
commit 544aa7c432
4 changed files with 44 additions and 1 deletions

View File

@@ -80,3 +80,36 @@ func TestEtcdConf_HasAccount(t *testing.T) {
assert.Equal(t, test.hasAccount, test.EtcdConf.HasAccount())
}
}
func TestEtcdConf_HasServerID(t *testing.T) {
tests := []struct {
EtcdConf
hasServerID bool
}{
{
EtcdConf: EtcdConf{
Hosts: []string{"any"},
ServerID: -1,
},
hasServerID: false,
},
{
EtcdConf: EtcdConf{
Hosts: []string{"any"},
ServerID: 0,
},
hasServerID: false,
},
{
EtcdConf: EtcdConf{
Hosts: []string{"any"},
ServerID: 10000,
},
hasServerID: true,
},
}
for _, test := range tests {
assert.Equal(t, test.hasServerID, test.EtcdConf.HasServerID())
}
}