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

Unified Diff: milo/appengine/swarming/html_test.go

Issue 2902323002: Milo: Swarming module test coverage (Closed)
Patch Set: Undo time change Created 3 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: milo/appengine/swarming/html_test.go
diff --git a/milo/appengine/swarming/html_test.go b/milo/appengine/swarming/html_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..eaa8483ed0886b5bd8d99854076413f41506d2fb
--- /dev/null
+++ b/milo/appengine/swarming/html_test.go
@@ -0,0 +1,72 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package swarming
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "net/url"
+ "testing"
+
+ "github.com/julienschmidt/httprouter"
+ "golang.org/x/net/context"
+
+ "github.com/luci/gae/impl/memory"
+ "github.com/luci/luci-go/common/clock/testclock"
+ "github.com/luci/luci-go/milo/appengine/common"
+ "github.com/luci/luci-go/server/auth"
+ "github.com/luci/luci-go/server/auth/authtest"
+ "github.com/luci/luci-go/server/auth/identity"
+ "github.com/luci/luci-go/server/router"
+ "github.com/luci/luci-go/server/templates"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func requestCtx(c context.Context, params ...httprouter.Param) *router.Context {
+ p := httprouter.Params(params)
+ r := &http.Request{URL: &url.URL{Path: "/foobar"}}
+ c = common.WithRequest(c, r)
+ w := httptest.NewRecorder()
+ return &router.Context{
+ Context: c,
+ Params: p,
+ Writer: w,
+ Request: r,
+ }
+}
+
+func TestHtml(t *testing.T) {
+ c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
+ c, _ = testclock.UseTime(c, testclock.TestTimeUTC)
+ c = templates.Use(c, common.GetTemplateBundle("../frontend/templates"))
+ c = auth.WithState(c, &authtest.FakeState{Identity: identity.AnonymousIdentity})
+
+ Convey(`HTML handler tests`, t, func() {
+ Convey(`Build pages`, func() {
+ Convey(`Empty request`, func() {
+ rc := requestCtx(c)
+ BuildHandler(rc)
+ response := rc.Writer.(*httptest.ResponseRecorder)
+ So(response.Code, ShouldEqual, http.StatusBadRequest)
+ })
+ Convey(`With id foo`, func() {
+ rc := requestCtx(c, httprouter.Param{"id", "foo"})
+ BuildHandler(rc)
+ response := rc.Writer.(*httptest.ResponseRecorder)
+ So(response.Code, ShouldEqual, http.StatusBadRequest)
+ })
+ })
+
+ Convey(`Log pages`, func() {
+ Convey(`Empty request`, func() {
+ rc := requestCtx(c)
+ LogHandler(rc)
+ response := rc.Writer.(*httptest.ResponseRecorder)
+ So(response.Code, ShouldEqual, http.StatusBadRequest)
+ })
+ })
+ })
+}
« no previous file with comments | « milo/appengine/swarming/expectations/build-gerrit.json ('k') | milo/appengine/swarming/testdata/build-gerrit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698