From 4bed34090f4a9029e49f6809d7652ff1e6d84758 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Tue, 17 Jan 2023 09:59:42 +0800 Subject: [PATCH] chore: add more tests (#2800) --- zrpc/resolver/internal/etcdbuilder_test.go | 11 +++++++++++ zrpc/resolver/internal/kubebuilder_test.go | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 zrpc/resolver/internal/etcdbuilder_test.go diff --git a/zrpc/resolver/internal/etcdbuilder_test.go b/zrpc/resolver/internal/etcdbuilder_test.go new file mode 100644 index 00000000..c67c4a01 --- /dev/null +++ b/zrpc/resolver/internal/etcdbuilder_test.go @@ -0,0 +1,11 @@ +package internal + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestEtcdBuilder_Scheme(t *testing.T) { + assert.Equal(t, EtcdScheme, new(etcdBuilder).Scheme()) +} diff --git a/zrpc/resolver/internal/kubebuilder_test.go b/zrpc/resolver/internal/kubebuilder_test.go index 9d86a46f..38a663d9 100644 --- a/zrpc/resolver/internal/kubebuilder_test.go +++ b/zrpc/resolver/internal/kubebuilder_test.go @@ -1,12 +1,25 @@ package internal import ( + "fmt" + "net/url" "testing" "github.com/stretchr/testify/assert" + "google.golang.org/grpc/resolver" ) func TestKubeBuilder_Scheme(t *testing.T) { var b kubeBuilder assert.Equal(t, KubernetesScheme, b.Scheme()) } + +func TestKubeBuilder_Build(t *testing.T) { + var b kubeBuilder + u, err := url.Parse(fmt.Sprintf("%s://%s", KubernetesScheme, "a,b")) + assert.NoError(t, err) + _, err = b.Build(resolver.Target{ + URL: *u, + }, nil, resolver.BuildOptions{}) + assert.Error(t, err) +}