| 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 buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 | 9 |
| 10 "github.com/luci/gae/impl/memory" | 10 "github.com/luci/gae/impl/memory" |
| 11 "github.com/luci/luci-go/common/clock/testclock" | 11 "github.com/luci/luci-go/common/clock/testclock" |
| 12 "github.com/luci/luci-go/milo/api/resp" | 12 "github.com/luci/luci-go/milo/api/resp" |
| 13 "github.com/luci/luci-go/milo/appengine/settings" | 13 "github.com/luci/luci-go/milo/appengine/settings" |
| 14 "github.com/luci/luci-go/server/templates" | 14 "github.com/luci/luci-go/server/templates" |
| 15 "golang.org/x/net/context" | 15 "golang.org/x/net/context" |
| 16 ) | 16 ) |
| 17 | 17 |
| 18 // We put this here because _test.go files are sometimes not built. | 18 // We put this here because _test.go files are sometimes not built. |
| 19 var testCases = []struct { | 19 var testCases = []struct { |
| 20 builder string | 20 builder string |
| 21 » build string | 21 » build int |
| 22 }{ | 22 }{ |
| 23 » {"CrWinGoma", "30608"}, | 23 » {"CrWinGoma", 30608}, |
| 24 » {"win_chromium_rel_ng", "246309"}, | 24 » {"win_chromium_rel_ng", 246309}, |
| 25 } | 25 } |
| 26 | 26 |
| 27 // TestableBuild is a subclass of Build that interfaces with TestableHandler and | 27 // TestableBuild is a subclass of Build that interfaces with TestableHandler and |
| 28 // includes sample test data. | 28 // includes sample test data. |
| 29 type TestableBuild struct{ Build } | 29 type TestableBuild struct{ Build } |
| 30 | 30 |
| 31 // TestableBuilder is a subclass of Builder that interfaces with TestableHandler | 31 // TestableBuilder is a subclass of Builder that interfaces with TestableHandler |
| 32 // and includes sample test data. | 32 // and includes sample test data. |
| 33 type TestableBuilder struct{ Builder } | 33 type TestableBuilder struct{ Builder } |
| 34 | 34 |
| 35 // TestData returns sample test data. | 35 // TestData returns sample test data. |
| 36 func (b Build) TestData() []settings.TestBundle { | 36 func (b Build) TestData() []settings.TestBundle { |
| 37 c := memory.Use(context.Background()) | 37 c := memory.Use(context.Background()) |
| 38 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | 38 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) |
| 39 bundles := []settings.TestBundle{} | 39 bundles := []settings.TestBundle{} |
| 40 for _, tc := range testCases { | 40 for _, tc := range testCases { |
| 41 build, err := build(c, "debug", tc.builder, tc.build) | 41 build, err := build(c, "debug", tc.builder, tc.build) |
| 42 if err != nil { | 42 if err != nil { |
| 43 panic(fmt.Errorf( | 43 panic(fmt.Errorf( |
| 44 "Encountered error while building debug/%s/%s.\n
%s", | 44 "Encountered error while building debug/%s/%s.\n
%s", |
| 45 tc.builder, tc.build, err)) | 45 tc.builder, tc.build, err)) |
| 46 } | 46 } |
| 47 bundles = append(bundles, settings.TestBundle{ | 47 bundles = append(bundles, settings.TestBundle{ |
| 48 » » » Description: fmt.Sprintf("Debug page: %s/%s", tc.builder
, tc.build), | 48 » » » Description: fmt.Sprintf("Debug page: %s/%d", tc.builder
, tc.build), |
| 49 Data: templates.Args{ | 49 Data: templates.Args{ |
| 50 "Build": build, | 50 "Build": build, |
| 51 }, | 51 }, |
| 52 }) | 52 }) |
| 53 } | 53 } |
| 54 return bundles | 54 return bundles |
| 55 } | 55 } |
| 56 | 56 |
| 57 // TestData returns sample test data. | 57 // TestData returns sample test data. |
| 58 func (b Builder) TestData() []settings.TestBundle { | 58 func (b Builder) TestData() []settings.TestBundle { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 Label: "Some cur
rent build", | 95 Label: "Some cur
rent build", |
| 96 }, | 96 }, |
| 97 Revision: "deadbeef", | 97 Revision: "deadbeef", |
| 98 }, | 98 }, |
| 99 }, | 99 }, |
| 100 }, | 100 }, |
| 101 }, | 101 }, |
| 102 }, | 102 }, |
| 103 } | 103 } |
| 104 } | 104 } |
| OLD | NEW |