OLD | NEW |
| (Empty) |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | |
2 // Use of this source code is governed under the Apache License, Version 2.0 | |
3 // that can be found in the LICENSE file. | |
4 | |
5 package frontend | |
6 | |
7 import ( | |
8 "fmt" | |
9 | |
10 "github.com/luci/gae/impl/memory" | |
11 "github.com/luci/luci-go/common/clock/testclock" | |
12 "github.com/luci/luci-go/milo/api/resp" | |
13 "github.com/luci/luci-go/milo/appengine/common" | |
14 "github.com/luci/luci-go/milo/appengine/job_source/buildbot" | |
15 "github.com/luci/luci-go/server/templates" | |
16 "golang.org/x/net/context" | |
17 ) | |
18 | |
19 // buildbotBuildTestData returns sample test data for build pages. | |
20 func buildbotBuildTestData() []common.TestBundle { | |
21 c := memory.Use(context.Background()) | |
22 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | |
23 bundles := []common.TestBundle{} | |
24 for _, tc := range buildbot.TestCases { | |
25 build, err := buildbot.DebugBuild(c, "../job_source/buildbot", t
c.Builder, tc.Build) | |
26 if err != nil { | |
27 panic(fmt.Errorf( | |
28 "Encountered error while building debug/%s/%s.\n
%s", | |
29 tc.Builder, tc.Build, err)) | |
30 } | |
31 bundles = append(bundles, common.TestBundle{ | |
32 Description: fmt.Sprintf("Debug page: %s/%d", tc.Builder
, tc.Build), | |
33 Data: templates.Args{ | |
34 "Build": build, | |
35 }, | |
36 }) | |
37 } | |
38 return bundles | |
39 } | |
40 | |
41 // buildbotBuilderTestData returns sample test data for builder pages. | |
42 func buildbotBuilderTestData() []common.TestBundle { | |
43 l := resp.NewLink("Some current build", "https://some.url/path") | |
44 return []common.TestBundle{ | |
45 { | |
46 Description: "Basic Test no builds", | |
47 Data: templates.Args{ | |
48 "Builder": &resp.Builder{ | |
49 Name: "Sample Builder", | |
50 }, | |
51 }, | |
52 }, | |
53 { | |
54 Description: "Basic Test with builds", | |
55 Data: templates.Args{ | |
56 "Builder": &resp.Builder{ | |
57 Name: "Sample Builder", | |
58 MachinePool: &resp.MachinePool{ | |
59 Total: 15, | |
60 Disconnected: 13, | |
61 Idle: 5, | |
62 Busy: 8, | |
63 }, | |
64 CurrentBuilds: []*resp.BuildSummary{ | |
65 {Link: l, Revision: "deadbeef"}, | |
66 }, | |
67 PendingBuilds: []*resp.BuildSummary{ | |
68 {Link: l, Revision: "deadbeef"}, | |
69 }, | |
70 FinishedBuilds: []*resp.BuildSummary{ | |
71 {Link: l, Revision: "deadbeef"}, | |
72 }, | |
73 }, | |
74 }, | |
75 }, | |
76 } | |
77 } | |
OLD | NEW |