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