| OLD | NEW |
| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 Convey("Testing basic rendering.", t, func() { | 88 Convey("Testing basic rendering.", t, func() { |
| 89 c := context.Background() | 89 c := context.Background() |
| 90 c = memory.Use(c) | 90 c = memory.Use(c) |
| 91 c = common.WithRequest(c, &http.Request{URL: &url.URL{Path: "/fo
obar"}}) | 91 c = common.WithRequest(c, &http.Request{URL: &url.URL{Path: "/fo
obar"}}) |
| 92 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | 92 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) |
| 93 c = auth.WithState(c, &authtest.FakeState{Identity: identity.Ano
nymousIdentity}) | 93 c = auth.WithState(c, &authtest.FakeState{Identity: identity.Ano
nymousIdentity}) |
| 94 c = settings.Use(c, settings.New(&settings.MemoryStorage{Expirat
ion: time.Second})) | 94 c = settings.Use(c, settings.New(&settings.MemoryStorage{Expirat
ion: time.Second})) |
| 95 err := settings.Set(c, "analytics", &analyticsSettings{"UA-12345
-01"}, "", "") | 95 err := settings.Set(c, "analytics", &analyticsSettings{"UA-12345
-01"}, "", "") |
| 96 So(err, ShouldBeNil) | 96 So(err, ShouldBeNil) |
| 97 » » c = templates.Use(c, common.GetTemplateBundle("templates")) | 97 » » c = templates.Use(c, common.GetTemplateBundle("appengine/templat
es")) |
| 98 for _, p := range allPackages { | 98 for _, p := range allPackages { |
| 99 Convey(fmt.Sprintf("Testing handler %q", p.DisplayName),
func() { | 99 Convey(fmt.Sprintf("Testing handler %q", p.DisplayName),
func() { |
| 100 for _, b := range p.Data() { | 100 for _, b := range p.Data() { |
| 101 Convey(fmt.Sprintf("Testing: %q", b.Desc
ription), func() { | 101 Convey(fmt.Sprintf("Testing: %q", b.Desc
ription), func() { |
| 102 args := b.Data | 102 args := b.Data |
| 103 // This is not a path, but a fil
e key, should always be "/". | 103 // This is not a path, but a fil
e key, should always be "/". |
| 104 tmplName := "pages/" + p.Templat
eName | 104 tmplName := "pages/" + p.Templat
eName |
| 105 buf, err := templates.Render(c,
tmplName, args) | 105 buf, err := templates.Render(c,
tmplName, args) |
| 106 So(err, ShouldBeNil) | 106 So(err, ShouldBeNil) |
| 107 fname := fmt.Sprintf( | 107 fname := fmt.Sprintf( |
| 108 "%s-%s.html", p.DisplayN
ame, b.Description) | 108 "%s-%s.html", p.DisplayN
ame, b.Description) |
| 109 if *generate { | 109 if *generate { |
| 110 mustWrite(fname, buf) | 110 mustWrite(fname, buf) |
| 111 } else { | 111 } else { |
| 112 localBuf, err := load(fn
ame) | 112 localBuf, err := load(fn
ame) |
| 113 So(err, ShouldBeNil) | 113 So(err, ShouldBeNil) |
| 114 So(fixZeroDuration(strin
g(buf)), ShouldEqual, fixZeroDuration(string(localBuf))) | 114 So(fixZeroDuration(strin
g(buf)), ShouldEqual, fixZeroDuration(string(localBuf))) |
| 115 } | 115 } |
| 116 }) | 116 }) |
| 117 } | 117 } |
| 118 }) | 118 }) |
| 119 } | 119 } |
| 120 }) | 120 }) |
| 121 } | 121 } |
| OLD | NEW |