From 60d75699e40c1e6188e06ed23468008d06b4eb92 Mon Sep 17 00:00:00 2001 From: "xinfei.wu" Date: Thu, 20 Dec 2018 13:52:07 +0800 Subject: [PATCH] fix test --- http_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/http_test.go b/http_test.go index 7aad22e..45c0a4c 100644 --- a/http_test.go +++ b/http_test.go @@ -11,6 +11,7 @@ import ( api "github.com/micro/go-api/proto" micro "github.com/micro/go-micro" + "github.com/micro/go-micro/broker" "github.com/micro/go-micro/client" "github.com/micro/go-micro/registry" "github.com/micro/go-micro/registry/mock" @@ -98,7 +99,10 @@ func TestSubscriber(t *testing.T) { reg := mock.NewRegistry() // create server - srv := NewServer(server.Registry(reg)) + srv := NewServer( + server.Registry(reg), + server.Broker(broker.NewBroker(broker.Registry(reg))), + ) // register handler if err := srv.Handle(srv.NewHandler(http.NewServeMux())); err != nil { @@ -133,6 +137,7 @@ func TestSubscriber(t *testing.T) { defer wg.Done() mClient := client.NewClient( client.Registry(reg), + client.Transport(srv.Options().Transport), client.Broker(srv.Options().Broker), ) pub := micro.NewPublisher(topic, mClient) @@ -148,6 +153,11 @@ func TestSubscriber(t *testing.T) { t.Fatalf("subscriber is not working, err: %s", ctx.Err()) } + // deregister server + if err := srv.Deregister(); err != nil { + t.Fatal(err) + } + // stop server if err := srv.Stop(); err != nil { t.Fatal(err)