Deprecate service (#1924)
This commit is contained in:
@@ -5,14 +5,13 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v3/client"
|
||||
cmucp "github.com/micro/go-micro/v3/client/mucp"
|
||||
"github.com/micro/go-micro/v3/registry/memory"
|
||||
"github.com/micro/go-micro/v3/server"
|
||||
"github.com/micro/go-micro/v3/service"
|
||||
"github.com/micro/go-micro/v3/service/mucp"
|
||||
"github.com/micro/go-micro/v3/server/mucp"
|
||||
)
|
||||
|
||||
type testHandler struct{}
|
||||
@@ -53,37 +52,31 @@ func TestHTTPProxy(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
reg := memory.NewRegistry()
|
||||
|
||||
// new micro service
|
||||
service := mucp.NewService(
|
||||
service.Context(ctx),
|
||||
service.Name("foobar"),
|
||||
service.Registry(memory.NewRegistry()),
|
||||
service.AfterStart(func() error {
|
||||
wg.Done()
|
||||
return nil
|
||||
}),
|
||||
)
|
||||
|
||||
// set router
|
||||
service.Server().Init(
|
||||
service := mucp.NewServer(
|
||||
server.Context(ctx),
|
||||
server.Name("foobar"),
|
||||
server.Registry(reg),
|
||||
server.WithRouter(p),
|
||||
)
|
||||
|
||||
service.Start()
|
||||
defer service.Stop()
|
||||
|
||||
// run service
|
||||
// server
|
||||
go http.Serve(c, nil)
|
||||
go service.Run()
|
||||
|
||||
// wait till service is started
|
||||
wg.Wait()
|
||||
cl := cmucp.NewClient(
|
||||
client.Registry(reg),
|
||||
)
|
||||
|
||||
for _, test := range testCases {
|
||||
req := service.Client().NewRequest("foobar", test.rpcEp, map[string]string{"foo": "bar"}, client.WithContentType("application/json"))
|
||||
req := cl.NewRequest("foobar", test.rpcEp, map[string]string{"foo": "bar"}, client.WithContentType("application/json"))
|
||||
var rsp map[string]string
|
||||
err := service.Client().Call(ctx, req, &rsp)
|
||||
err := cl.Call(ctx, req, &rsp)
|
||||
if err != nil && test.err == false {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user