| Index: server/prpc/server_test.go
|
| diff --git a/server/prpc/server_test.go b/server/prpc/server_test.go
|
| index 664896045d792cad83fb3e97a48bc7e3065461f4..ea41b787968518e6cd2869b9d87f946c51f6d87b 100644
|
| --- a/server/prpc/server_test.go
|
| +++ b/server/prpc/server_test.go
|
| @@ -4,29 +4,28 @@
|
|
|
| package prpc
|
|
|
| import (
|
| "bytes"
|
| "net/http"
|
| "net/http/httptest"
|
| "strconv"
|
| "testing"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| "golang.org/x/net/context"
|
| "google.golang.org/grpc"
|
| "google.golang.org/grpc/codes"
|
|
|
| "github.com/luci/luci-go/common/prpc"
|
| prpccommon "github.com/luci/luci-go/common/prpc"
|
| "github.com/luci/luci-go/server/auth"
|
| - "github.com/luci/luci-go/server/middleware"
|
| + "github.com/luci/luci-go/server/router"
|
|
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| type greeterService struct{}
|
|
|
| func (s *greeterService) SayHello(c context.Context, req *HelloRequest) (*HelloReply, error) {
|
| if req.Name == "" {
|
| return nil, grpc.Errorf(codes.InvalidArgument, "Name unspecified")
|
| }
|
| @@ -58,22 +57,27 @@ func TestServer(t *testing.T) {
|
| Convey("Register Calc service", func() {
|
| RegisterCalcServer(&server, &calcService{})
|
| So(server.ServiceNames(), ShouldResemble, []string{
|
| "prpc.Calc",
|
| "prpc.Greeter",
|
| })
|
| })
|
|
|
| Convey("Handlers", func() {
|
| c := context.Background()
|
| - r := httprouter.New()
|
| - server.InstallHandlers(r, middleware.TestingBase(c))
|
| + r := router.New()
|
| + server.InstallHandlers(r, router.MiddlewareChain{
|
| + func(ctx *router.Context, next router.Handler) {
|
| + ctx.Context = c
|
| + next(ctx)
|
| + },
|
| + })
|
| res := httptest.NewRecorder()
|
| hiMsg := bytes.NewBufferString(`name: "Lucy"`)
|
| req, err := http.NewRequest("POST", "/prpc/prpc.Greeter/SayHello", hiMsg)
|
| So(err, ShouldBeNil)
|
| req.Header.Set("Content-Type", mtPRPCText)
|
|
|
| invalidArgument := strconv.Itoa(int(codes.InvalidArgument))
|
| unimplemented := strconv.Itoa(int(codes.Unimplemented))
|
|
|
| Convey("Works", func() {
|
|
|