2021-12-01 20:22:15 +08:00
|
|
|
package resolver
|
2020-08-24 23:09:46 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestBuildDirectTarget(t *testing.T) {
|
|
|
|
|
target := BuildDirectTarget([]string{"localhost:123", "localhost:456"})
|
|
|
|
|
assert.Equal(t, "direct:///localhost:123,localhost:456", target)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildDiscovTarget(t *testing.T) {
|
|
|
|
|
target := BuildDiscovTarget([]string{"localhost:123", "localhost:456"}, "foo")
|
2026-04-25 10:48:28 +08:00
|
|
|
assert.Equal(t, "etcd:///localhost:123,localhost:456?key=foo", target)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestBuildDiscovTargetWithSlashKey(t *testing.T) {
|
|
|
|
|
target := BuildDiscovTarget([]string{"localhost:2379"}, "/grpc/my-service")
|
|
|
|
|
assert.Equal(t, "etcd:///localhost:2379?key=%2Fgrpc%2Fmy-service", target)
|
2020-08-24 23:09:46 +08:00
|
|
|
}
|