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

Unified Diff: appengine/tsmon/global_callback_test.go

Issue 2043423004: Make HTTP middleware easier to use (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Update tests 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
Index: appengine/tsmon/global_callback_test.go
diff --git a/appengine/tsmon/global_callback_test.go b/appengine/tsmon/global_callback_test.go
index 0fb98c08efb54b865d78af650b2559a56eadf344..e88a7a30902910219193735eed204c9d90976675 100644
--- a/appengine/tsmon/global_callback_test.go
+++ b/appengine/tsmon/global_callback_test.go
@@ -10,11 +10,11 @@ import (
"testing"
"time"
- "github.com/julienschmidt/httprouter"
"github.com/luci/gae/service/datastore"
"github.com/luci/luci-go/common/clock"
"github.com/luci/luci-go/common/tsmon"
"github.com/luci/luci-go/common/tsmon/metric"
+ "github.com/luci/luci-go/server/router"
"golang.org/x/net/context"
. "github.com/smartystreets/goconvey/convey"
@@ -33,7 +33,9 @@ func flushNowWithMiddleware(c context.Context, state *State) {
state.lastFlushed = clock.Now(c).Add(-2 * time.Minute)
rec := httptest.NewRecorder()
- state.Middleware(func(c context.Context, rw http.ResponseWriter, r *http.Request, p httprouter.Params) {})(c, rec, &http.Request{}, nil)
+ router.ChainHandlers(func(ctx *router.Context) {
+ ctx.Context, ctx.Writer, ctx.Request = c, rec, &http.Request{}
+ }, state.Middleware())()
So(rec.Code, ShouldEqual, http.StatusOK)
}
@@ -60,7 +62,9 @@ func TestGlobalCallbacks(t *testing.T) {
s := tsmon.Store(c)
rec := httptest.NewRecorder()
- housekeepingHandler(c, rec, &http.Request{}, nil)
+ router.ChainHandlers(func(ctx *router.Context) {
+ ctx.Context, ctx.Writer, ctx.Request = c, rec, &http.Request{}
+ }, housekeepingHandler)()
So(rec.Code, ShouldEqual, http.StatusOK)
val, err := s.Get(c, m, time.Time{}, []interface{}{})

Powered by Google App Engine
This is Rietveld 408576698