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

Side by Side Diff: milo/appengine/frontend/milo_test.go

Issue 2248893002: Settings page for analytics ID (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: y Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package frontend 5 package frontend
6 6
7 import ( 7 import (
8 "flag" 8 "flag"
9 "fmt" 9 "fmt"
10 "io/ioutil" 10 "io/ioutil"
11 "net/http" 11 "net/http"
12 "path/filepath" 12 "path/filepath"
13 "reflect" 13 "reflect"
14 "strings" 14 "strings"
15 "testing" 15 "testing"
16 "time"
16 17
17 "github.com/luci/gae/impl/memory" 18 "github.com/luci/gae/impl/memory"
18 "github.com/luci/luci-go/common/clock/testclock" 19 "github.com/luci/luci-go/common/clock/testclock"
19 "github.com/luci/luci-go/milo/appengine/buildbot" 20 "github.com/luci/luci-go/milo/appengine/buildbot"
20 "github.com/luci/luci-go/milo/appengine/settings" 21 "github.com/luci/luci-go/milo/appengine/settings"
21 "github.com/luci/luci-go/milo/appengine/swarming" 22 "github.com/luci/luci-go/milo/appengine/swarming"
22 "github.com/luci/luci-go/server/auth" 23 "github.com/luci/luci-go/server/auth"
23 "github.com/luci/luci-go/server/auth/identity" 24 "github.com/luci/luci-go/server/auth/identity"
25 luciSettings "github.com/luci/luci-go/server/settings"
24 . "github.com/smartystreets/goconvey/convey" 26 . "github.com/smartystreets/goconvey/convey"
25 "golang.org/x/net/context" 27 "golang.org/x/net/context"
26 ) 28 )
27 29
28 var ( 30 var (
29 allHandlers = []settings.TestableHandler{ 31 allHandlers = []settings.TestableHandler{
30 settings.TestableSettings{}, 32 settings.TestableSettings{},
31 buildbot.TestableBuild{}, 33 buildbot.TestableBuild{},
32 buildbot.TestableBuilder{}, 34 buildbot.TestableBuilder{},
33 swarming.TestableBuild{}, 35 swarming.TestableBuild{},
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 78 }
77 79
78 func (m fakeOAuthMethod) LoginURL(context.Context, string) (string, error) { 80 func (m fakeOAuthMethod) LoginURL(context.Context, string) (string, error) {
79 return "https://login.url/", nil 81 return "https://login.url/", nil
80 } 82 }
81 83
82 func (m fakeOAuthMethod) LogoutURL(context.Context, string) (string, error) { 84 func (m fakeOAuthMethod) LogoutURL(context.Context, string) (string, error) {
83 return "https://logout.url/", nil 85 return "https://logout.url/", nil
84 } 86 }
85 87
88 type analyticsSettings struct {
89 AnalyticsID string `json:"analytics_id"`
90 }
91
86 func TestPages(t *testing.T) { 92 func TestPages(t *testing.T) {
87 Convey("Testing basic rendering.", t, func() { 93 Convey("Testing basic rendering.", t, func() {
88 // Load all the bundles. 94 // Load all the bundles.
89 c := context.Background() 95 c := context.Background()
90 c = memory.Use(c) 96 c = memory.Use(c)
91 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) 97 c, _ = testclock.UseTime(c, testclock.TestTimeUTC)
92 a := auth.Authenticator{fakeOAuthMethod{"some_client_id"}} 98 a := auth.Authenticator{fakeOAuthMethod{"some_client_id"}}
93 c = auth.SetAuthenticator(c, a) 99 c = auth.SetAuthenticator(c, a)
94 100 » » c = luciSettings.Use(c, luciSettings.New(&luciSettings.MemorySto rage{Expiration: time.Second}))
101 » » err := luciSettings.Set(c, "analytics", &analyticsSettings{"UA-1 2345-01"}, "", "")
102 » » So(err, ShouldBeNil)
95 for _, nb := range settings.GetTemplateBundles() { 103 for _, nb := range settings.GetTemplateBundles() {
96 Convey(fmt.Sprintf("Testing theme %q", nb.Name), func() { 104 Convey(fmt.Sprintf("Testing theme %q", nb.Name), func() {
97 err := nb.Bundle.EnsureLoaded(c) 105 err := nb.Bundle.EnsureLoaded(c)
98 So(err, ShouldBeNil) 106 So(err, ShouldBeNil)
99 for _, h := range allHandlers { 107 for _, h := range allHandlers {
100 hName := reflect.TypeOf(h).String() 108 hName := reflect.TypeOf(h).String()
101 Convey(fmt.Sprintf("Testing handler %q", hName), func() { 109 Convey(fmt.Sprintf("Testing handler %q", hName), func() {
102 for _, b := range h.TestData() { 110 for _, b := range h.TestData() {
103 Convey(fmt.Sprintf("Test ing: %q", b.Description), func() { 111 Convey(fmt.Sprintf("Test ing: %q", b.Description), func() {
104 args := b.Data 112 args := b.Data
(...skipping 12 matching lines...) Expand all
117 So(strin g(buf), ShouldEqual, string(localBuf)) 125 So(strin g(buf), ShouldEqual, string(localBuf))
118 } 126 }
119 }) 127 })
120 } 128 }
121 }) 129 })
122 } 130 }
123 }) 131 })
124 } 132 }
125 }) 133 })
126 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698