Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: milo/buildsource/buildbot/console_test.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: make manifestkey its own type Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 buildbot
16
17 import (
18 "context"
19 "strconv"
20 "testing"
21
22 "github.com/luci/gae/impl/memory"
23 "github.com/luci/gae/service/datastore"
24 "github.com/luci/luci-go/common/clock/testclock"
25 "github.com/luci/luci-go/milo/api/resp"
26
27 . "github.com/smartystreets/goconvey/convey"
28 )
29
30 func TestConsole(t *testing.T) {
31 c := memory.UseWithAppID(context.Background(), "dev~luci-milo")
32 c, _ = testclock.UseTime(c, testclock.TestTimeUTC)
33 fakeTime := float64(123)
34 fakeResult := int(0)
35
36 // Seed a builder with 8 builds.
37 for i := 1; i < 10; i++ {
38 datastore.Put(c, &buildbotBuild{
39 Master: "fake",
40 Buildername: "fake",
41 Number: i,
42 Internal: false,
43 Times: []*float64{&fakeTime, &fakeTime},
44 Sourcestamp: &buildbotSourceStamp{
45 Revision: strconv.Itoa(i),
46 },
47 Results: &fakeResult,
48 Finished: true,
49 })
50 }
51 putDSMasterJSON(c, &buildbotMaster{
52 Name: "fake",
53 Builders: map[string]*buildbotBuilder{"fake": {}},
54 }, false)
55 datastore.GetTestable(c).Consistent(true)
56 datastore.GetTestable(c).AutoIndex(true)
57 datastore.GetTestable(c).CatchupIndexes()
58
59 Convey(`Console tests for buildbot`, t, func() {
60 Convey(`Empty request`, func() {
61 cb, err := GetConsoleBuilds(c, []resp.BuilderRef{}, []st ring{})
62 So(err, ShouldBeNil)
63 So(cb, ShouldResemble, [][]*resp.ConsoleBuild{})
64 })
65 Convey(`Basic`, func() {
66 ref := []resp.BuilderRef{
67 {
68 Name: "buildbot/fake/fake",
69 Category: []string{"np"},
70 ShortName: "np",
71 },
72 }
73 cb, err := GetConsoleBuilds(c, ref, []string{"2", "3", " 5"})
74 So(err, ShouldBeNil)
75 So(len(cb), ShouldEqual, 3)
76 So(len(cb[0]), ShouldEqual, 1)
77 })
78 })
79 }
OLDNEW
« no previous file with comments | « milo/buildsource/buildbot/console.go ('k') | milo/buildsource/buildbot/expectations/CrWinGoma.30608.build.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698