package zrpc import ( "testing" "git.i2edu.net/i2/go-zero/core/discov" "git.i2edu.net/i2/go-zero/core/service" "git.i2edu.net/i2/go-zero/core/stores/redis" "github.com/stretchr/testify/assert" ) func TestRpcClientConf(t *testing.T) { conf := NewDirectClientConf([]string{"localhost:1234"}, "foo", "bar") assert.True(t, conf.HasCredential()) conf = NewEtcdClientConf([]string{"localhost:1234", "localhost:5678"}, "key", "foo", "bar") assert.True(t, conf.HasCredential()) } func TestRpcServerConf(t *testing.T) { conf := RpcServerConf{ ServiceConf: service.ServiceConf{}, ListenOn: "", Etcd: discov.EtcdConf{ Hosts: []string{"localhost:1234"}, Key: "key", }, Auth: true, Redis: redis.RedisKeyConf{ RedisConf: redis.RedisConf{ Type: redis.NodeType, }, Key: "foo", }, StrictControl: false, Timeout: 0, CpuThreshold: 0, } assert.True(t, conf.HasEtcd()) assert.NotNil(t, conf.Validate()) conf.Redis.Host = "localhost:5678" assert.Nil(t, conf.Validate()) }