Chromium Code Reviews| Index: milo/appengine/frontend/milo_test.go |
| diff --git a/milo/appengine/frontend/milo_test.go b/milo/appengine/frontend/milo_test.go |
| index 3fb78b6a9261c938e93d6f916ca0330355c7701f..812b0646373939161f392fd73b31204ea99348b4 100644 |
| --- a/milo/appengine/frontend/milo_test.go |
| +++ b/milo/appengine/frontend/milo_test.go |
| @@ -11,7 +11,6 @@ import ( |
| "net/http" |
| "net/url" |
| "path/filepath" |
| - "reflect" |
| "regexp" |
| "strings" |
| "testing" |
| @@ -25,18 +24,24 @@ import ( |
| "github.com/luci/luci-go/server/auth" |
| "github.com/luci/luci-go/server/auth/identity" |
| luciSettings "github.com/luci/luci-go/server/settings" |
| + "github.com/luci/luci-go/server/templates" |
| . "github.com/smartystreets/goconvey/convey" |
| "golang.org/x/net/context" |
|
nodir
2017/03/16 17:42:51
nit: this import should go before imports of "our"
hinoka
2017/03/17 20:00:21
Done.
|
| ) |
| +type testPackage struct { |
| + Data func() []settings.TestBundle |
| + DisplayName string |
| + TemplateName string |
| +} |
| + |
| var ( |
| - allHandlers = []settings.TestableHandler{ |
| - settings.TestableSettings{}, |
| - buildbot.TestableBuild{}, |
| - buildbot.TestableBuilder{}, |
| - swarming.TestableBuild{}, |
| - swarming.TestableLog{}, |
| - testableFrontpage{}, |
| + allPackages = []testPackage{ |
| + {buildbot.BuildTestData, "buildbot.build", "build.html"}, |
| + {buildbot.BuilderTestData, "buildbot.builder", "builder.html"}, |
| + {swarming.BuildTestData, "swarming.build", "build.html"}, |
| + {swarming.LogTestData, "swarming.log", "log.html"}, |
| + {frontpageTestData, "frontpage", "frontpage.html"}, |
| } |
| ) |
| @@ -108,31 +113,24 @@ func TestPages(t *testing.T) { |
| c = luciSettings.Use(c, luciSettings.New(&luciSettings.MemoryStorage{Expiration: time.Second})) |
| err := luciSettings.Set(c, "analytics", &analyticsSettings{"UA-12345-01"}, "", "") |
| So(err, ShouldBeNil) |
| - for _, nb := range settings.GetTemplateBundles() { |
| - Convey(fmt.Sprintf("Testing theme %q", nb.Name), func() { |
| - err := nb.Bundle.EnsureLoaded(c) |
| - So(err, ShouldBeNil) |
| - for _, h := range allHandlers { |
| - hName := reflect.TypeOf(h).String() |
| - Convey(fmt.Sprintf("Testing handler %q", hName), func() { |
| - for _, b := range h.TestData() { |
| - Convey(fmt.Sprintf("Testing: %q", b.Description), func() { |
| - args := b.Data |
| - // This is not a path, but a file key, should always be "/". |
| - tmplName := fmt.Sprintf( |
| - "pages/%s", h.GetTemplateName(*nb.Theme)) |
| - buf, err := nb.Bundle.Render(c, tmplName, args) |
| - So(err, ShouldBeNil) |
| - fname := fmt.Sprintf( |
| - "%s-%s-%s.html", nb.Name, hName, b.Description) |
| - if *generate { |
| - mustWrite(fname, buf) |
| - } else { |
| - localBuf, err := load(fname) |
| - So(err, ShouldBeNil) |
| - So(fixZeroDuration(string(buf)), ShouldEqual, fixZeroDuration(string(localBuf))) |
| - } |
| - }) |
| + c = templates.Use(c, settings.GetTemplateBundle()) |
| + for _, p := range allPackages { |
| + Convey(fmt.Sprintf("Testing handler %q", p.DisplayName), func() { |
| + for _, b := range p.Data() { |
| + Convey(fmt.Sprintf("Testing: %q", b.Description), func() { |
| + args := b.Data |
| + // This is not a path, but a file key, should always be "/". |
| + tmplName := "pages/" + p.TemplateName |
| + buf, err := templates.Render(c, tmplName, args) |
| + So(err, ShouldBeNil) |
| + fname := fmt.Sprintf( |
| + "%s-%s.html", p.DisplayName, b.Description) |
| + if *generate { |
| + mustWrite(fname, buf) |
| + } else { |
| + localBuf, err := load(fname) |
| + So(err, ShouldBeNil) |
| + So(fixZeroDuration(string(buf)), ShouldEqual, fixZeroDuration(string(localBuf))) |
| } |
| }) |
| } |