fix http test

This commit is contained in:
Asim Aslam 2020-04-08 19:20:43 +01:00
parent b2079669f7
commit 48dd30c4c2

View File

@ -13,7 +13,7 @@ import (
"github.com/micro/go-micro/v2/registry/memory" "github.com/micro/go-micro/v2/registry/memory"
) )
func testHttp(t *testing.T, path, service, ns string) { func testHttp(t *testing.T, path, service string) {
r := memory.NewRegistry() r := memory.NewRegistry()
l, err := net.Listen("tcp", "127.0.0.1:0") l, err := net.Listen("tcp", "127.0.0.1:0")
@ -54,7 +54,6 @@ func testHttp(t *testing.T, path, service, ns string) {
// initialise the handler // initialise the handler
rt := regRouter.NewRouter( rt := regRouter.NewRouter(
router.WithHandler("http"), router.WithHandler("http"),
router.WithNamespace(ns),
router.WithRegistry(r), router.WithRegistry(r),
) )
@ -74,48 +73,40 @@ func testHttp(t *testing.T, path, service, ns string) {
func TestHttpHandler(t *testing.T) { func TestHttpHandler(t *testing.T) {
testData := []struct { testData := []struct {
path string path string
service string service string
namespace string
}{ }{
{ {
"/test/foo", "/test/foo",
"go.micro.api.test", "test",
"go.micro.api",
}, },
{ {
"/test/foo/baz", "/test/foo/baz",
"go.micro.api.test", "test",
"go.micro.api",
}, },
{ {
"/v1/foo", "/v1/foo",
"go.micro.api.v1.foo", "v1.foo",
"go.micro.api",
}, },
{ {
"/v1/foo/bar", "/v1/foo/bar",
"go.micro.api.v1.foo", "v1.foo",
"go.micro.api",
}, },
{ {
"/v2/baz", "/v2/baz",
"go.micro.api.v2.baz", "v2.baz",
"go.micro.api", },
}, {
{ "/v2/baz/bar",
"/v2/baz/bar", "v2.baz",
"go.micro.api.v2.baz",
"go.micro.api",
}, },
{ {
"/v2/baz/bar", "/v2/baz/bar",
"v2.baz", "v2.baz",
"",
}, },
} }
for _, d := range testData { for _, d := range testData {
testHttp(t, d.path, d.service, d.namespace) testHttp(t, d.path, d.service)
} }
} }