| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The LUCI Authors. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 package frontend | |
| 16 | |
| 17 import ( | |
| 18 "fmt" | |
| 19 | |
| 20 "github.com/luci/gae/impl/memory" | |
| 21 "github.com/luci/luci-go/common/clock/testclock" | |
| 22 "github.com/luci/luci-go/milo/api/resp" | |
| 23 "github.com/luci/luci-go/milo/buildsource/buildbot" | |
| 24 "github.com/luci/luci-go/milo/common" | |
| 25 "github.com/luci/luci-go/server/templates" | |
| 26 "golang.org/x/net/context" | |
| 27 ) | |
| 28 | |
| 29 // buildbotBuildTestData returns sample test data for build pages. | |
| 30 func buildbotBuildTestData() []common.TestBundle { | |
| 31 c := memory.Use(context.Background()) | |
| 32 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | |
| 33 bundles := []common.TestBundle{} | |
| 34 for _, tc := range buildbot.TestCases { | |
| 35 build, err := buildbot.DebugBuild(c, "../buildsource/buildbot",
tc.Builder, tc.Build) | |
| 36 if err != nil { | |
| 37 panic(fmt.Errorf( | |
| 38 "Encountered error while building debug/%s/%s.\n
%s", | |
| 39 tc.Builder, tc.Build, err)) | |
| 40 } | |
| 41 bundles = append(bundles, common.TestBundle{ | |
| 42 Description: fmt.Sprintf("Debug page: %s/%d", tc.Builder
, tc.Build), | |
| 43 Data: templates.Args{ | |
| 44 "Build": build, | |
| 45 }, | |
| 46 }) | |
| 47 } | |
| 48 return bundles | |
| 49 } | |
| 50 | |
| 51 // buildbotBuilderTestData returns sample test data for builder pages. | |
| 52 func buildbotBuilderTestData() []common.TestBundle { | |
| 53 l := resp.NewLink("Some current build", "https://some.url/path") | |
| 54 return []common.TestBundle{ | |
| 55 { | |
| 56 Description: "Basic Test no builds", | |
| 57 Data: templates.Args{ | |
| 58 "Builder": &resp.Builder{ | |
| 59 Name: "Sample Builder", | |
| 60 }, | |
| 61 }, | |
| 62 }, | |
| 63 { | |
| 64 Description: "Basic Test with builds", | |
| 65 Data: templates.Args{ | |
| 66 "Builder": &resp.Builder{ | |
| 67 Name: "Sample Builder", | |
| 68 MachinePool: &resp.MachinePool{ | |
| 69 Total: 15, | |
| 70 Disconnected: 13, | |
| 71 Idle: 5, | |
| 72 Busy: 8, | |
| 73 }, | |
| 74 CurrentBuilds: []*resp.BuildSummary{ | |
| 75 {Link: l, Revision: "deadbeef"}, | |
| 76 }, | |
| 77 PendingBuilds: []*resp.BuildSummary{ | |
| 78 {Link: l, Revision: "deadbeef"}, | |
| 79 }, | |
| 80 FinishedBuilds: []*resp.BuildSummary{ | |
| 81 {Link: l, Revision: "deadbeef"}, | |
| 82 }, | |
| 83 }, | |
| 84 }, | |
| 85 }, | |
| 86 } | |
| 87 } | |
| OLD | NEW |