Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Unified Diff: server/prpc/server_test.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: gaemiddleware: add middleware func for WithProd Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « server/prpc/server.go ('k') | server/router/example_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « server/prpc/server.go ('k') | server/router/example_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698