| 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 frontend |
| 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/buildbot" |
| 13 "github.com/luci/luci-go/milo/appengine/common" | 14 "github.com/luci/luci-go/milo/appengine/common" |
| 14 "github.com/luci/luci-go/server/templates" | 15 "github.com/luci/luci-go/server/templates" |
| 15 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
| 16 ) | 17 ) |
| 17 | 18 |
| 18 // We put this here because _test.go files are sometimes not built. | 19 // buildbotBuildTestData returns sample test data for build pages. |
| 19 var testCases = []struct { | 20 func buildbotBuildTestData() []common.TestBundle { |
| 20 » builder string | |
| 21 » build int | |
| 22 }{ | |
| 23 » {"CrWinGoma", 30608}, | |
| 24 » {"win_chromium_rel_ng", 246309}, | |
| 25 » {"newline", 1234}, | |
| 26 } | |
| 27 | |
| 28 // BuildTestData returns sample test data for build pages. | |
| 29 func BuildTestData() []common.TestBundle { | |
| 30 c := memory.Use(context.Background()) | 21 c := memory.Use(context.Background()) |
| 31 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | 22 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) |
| 32 bundles := []common.TestBundle{} | 23 bundles := []common.TestBundle{} |
| 33 » for _, tc := range testCases { | 24 » for _, tc := range buildbot.TestCases { |
| 34 » » build, err := build(c, "debug", tc.builder, tc.build) | 25 » » build, err := buildbot.Build(c, "debug", tc.Builder, tc.Build) |
| 35 if err != nil { | 26 if err != nil { |
| 36 panic(fmt.Errorf( | 27 panic(fmt.Errorf( |
| 37 "Encountered error while building debug/%s/%s.\n
%s", | 28 "Encountered error while building debug/%s/%s.\n
%s", |
| 38 » » » » tc.builder, tc.build, err)) | 29 » » » » tc.Builder, tc.Build, err)) |
| 39 } | 30 } |
| 40 bundles = append(bundles, common.TestBundle{ | 31 bundles = append(bundles, common.TestBundle{ |
| 41 » » » Description: fmt.Sprintf("Debug page: %s/%d", tc.builder
, tc.build), | 32 » » » Description: fmt.Sprintf("Debug page: %s/%d", tc.Builder
, tc.Build), |
| 42 Data: templates.Args{ | 33 Data: templates.Args{ |
| 43 "Build": build, | 34 "Build": build, |
| 44 }, | 35 }, |
| 45 }) | 36 }) |
| 46 } | 37 } |
| 47 return bundles | 38 return bundles |
| 48 } | 39 } |
| 49 | 40 |
| 50 // BiulderTestData returns sample test data for builder pages. | 41 // buildbotBuilderTestData returns sample test data for builder pages. |
| 51 func BuilderTestData() []common.TestBundle { | 42 func buildbotBuilderTestData() []common.TestBundle { |
| 52 return []common.TestBundle{ | 43 return []common.TestBundle{ |
| 53 { | 44 { |
| 54 Description: "Basic Test no builds", | 45 Description: "Basic Test no builds", |
| 55 Data: templates.Args{ | 46 Data: templates.Args{ |
| 56 "Builder": &resp.Builder{ | 47 "Builder": &resp.Builder{ |
| 57 Name: "Sample Builder", | 48 Name: "Sample Builder", |
| 58 }, | 49 }, |
| 59 }, | 50 }, |
| 60 }, | 51 }, |
| 61 { | 52 { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 88 Label: "Some cur
rent build", | 79 Label: "Some cur
rent build", |
| 89 }, | 80 }, |
| 90 Revision: "deadbeef", | 81 Revision: "deadbeef", |
| 91 }, | 82 }, |
| 92 }, | 83 }, |
| 93 }, | 84 }, |
| 94 }, | 85 }, |
| 95 }, | 86 }, |
| 96 } | 87 } |
| 97 } | 88 } |
| OLD | NEW |