From 271238abf2f97c4f48f466e71641382b7b5257d1 Mon Sep 17 00:00:00 2001 From: Kevin Parsons Date: Fri, 23 Aug 2019 13:04:39 -0700 Subject: [PATCH] Fix method full name generation Signed-off-by: Kevin Parsons --- services.go | 2 +- services_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 services_test.go diff --git a/services.go b/services.go index 655b2caea..0eacfd79a 100644 --- a/services.go +++ b/services.go @@ -152,5 +152,5 @@ func convertCode(err error) codes.Code { } func fullPath(service, method string) string { - return "/" + path.Join("/", service, method) + return "/" + path.Join(service, method) } diff --git a/services_test.go b/services_test.go new file mode 100644 index 000000000..0746a3412 --- /dev/null +++ b/services_test.go @@ -0,0 +1,29 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package ttrpc + +import ( + "testing" +) + +func Test_MethodFullNameGeneration(t *testing.T) { + name := fullPath("test.v1.service", "Foo") + expectedName := "/test.v1.service/Foo" + if name != expectedName { + t.Fatalf("Service name does not match. Expected: %q, Actual: %q", expectedName, name) + } +}