Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Aug 26, 2020
1 parent 30e5270 commit 1a8014c
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions rpcx/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package rpcx

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/tal-tech/go-zero/core/discov"
"github.com/tal-tech/go-zero/core/service"
"github.com/tal-tech/go-zero/core/stores/redis"
)

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())
}

0 comments on commit 1a8014c

Please sign in to comment.