chore: add more tests (#2812)

* chore: add more tests

* chore: add more tests
This commit is contained in:
Kevin Wan
2023-01-23 23:27:47 +08:00
committed by GitHub
parent f3369f8e81
commit 4bd8025c5b
4 changed files with 47 additions and 8 deletions

View File

@@ -10,10 +10,35 @@ import (
)
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())
t.Run("direct", func(t *testing.T) {
conf := NewDirectClientConf([]string{"localhost:1234"}, "foo", "bar")
assert.True(t, conf.HasCredential())
})
t.Run("etcd", func(t *testing.T) {
conf := NewEtcdClientConf([]string{"localhost:1234", "localhost:5678"},
"key", "foo", "bar")
assert.True(t, conf.HasCredential())
})
t.Run("etcd with account", func(t *testing.T) {
conf := NewEtcdClientConf([]string{"localhost:1234", "localhost:5678"},
"key", "foo", "bar")
conf.Etcd.User = "user"
conf.Etcd.Pass = "pass"
_, err := conf.BuildTarget()
assert.NoError(t, err)
})
t.Run("etcd with tls", func(t *testing.T) {
conf := NewEtcdClientConf([]string{"localhost:1234", "localhost:5678"},
"key", "foo", "bar")
conf.Etcd.CertFile = "cert"
conf.Etcd.CertKeyFile = "key"
conf.Etcd.CACertFile = "ca"
_, err := conf.BuildTarget()
assert.Error(t, err)
})
}
func TestRpcServerConf(t *testing.T) {