| OLD | NEW |
| (Empty) |
| 1 // Copyright 2017 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 buildbot | |
| 6 | |
| 7 import ( | |
| 8 "context" | |
| 9 "strconv" | |
| 10 "testing" | |
| 11 | |
| 12 "github.com/luci/gae/impl/memory" | |
| 13 "github.com/luci/gae/service/datastore" | |
| 14 "github.com/luci/luci-go/common/clock/testclock" | |
| 15 "github.com/luci/luci-go/milo/api/resp" | |
| 16 | |
| 17 . "github.com/smartystreets/goconvey/convey" | |
| 18 ) | |
| 19 | |
| 20 func TestConsole(t *testing.T) { | |
| 21 c := memory.UseWithAppID(context.Background(), "dev~luci-milo") | |
| 22 c, _ = testclock.UseTime(c, testclock.TestTimeUTC) | |
| 23 fakeTime := float64(123) | |
| 24 fakeResult := int(0) | |
| 25 | |
| 26 // Seed a builder with 8 builds. | |
| 27 for i := 1; i < 10; i++ { | |
| 28 datastore.Put(c, &buildbotBuild{ | |
| 29 Master: "fake", | |
| 30 Buildername: "fake", | |
| 31 Number: i, | |
| 32 Internal: false, | |
| 33 Times: []*float64{&fakeTime, &fakeTime}, | |
| 34 Sourcestamp: &buildbotSourceStamp{ | |
| 35 Revision: strconv.Itoa(i), | |
| 36 }, | |
| 37 Results: &fakeResult, | |
| 38 Finished: true, | |
| 39 }) | |
| 40 } | |
| 41 putDSMasterJSON(c, &buildbotMaster{ | |
| 42 Name: "fake", | |
| 43 Builders: map[string]*buildbotBuilder{"fake": {}}, | |
| 44 }, false) | |
| 45 datastore.GetTestable(c).Consistent(true) | |
| 46 datastore.GetTestable(c).AutoIndex(true) | |
| 47 datastore.GetTestable(c).CatchupIndexes() | |
| 48 | |
| 49 Convey(`Console tests for buildbot`, t, func() { | |
| 50 Convey(`Empty request`, func() { | |
| 51 cb, err := GetConsoleBuilds(c, []resp.BuilderRef{}, []st
ring{}) | |
| 52 So(err, ShouldBeNil) | |
| 53 So(cb, ShouldResemble, [][]*resp.ConsoleBuild{}) | |
| 54 }) | |
| 55 Convey(`Basic`, func() { | |
| 56 ref := []resp.BuilderRef{ | |
| 57 { | |
| 58 Module: "buildbot", | |
| 59 Name: "fake/fake", | |
| 60 Category: []string{"np"}, | |
| 61 ShortName: "np", | |
| 62 }, | |
| 63 } | |
| 64 cb, err := GetConsoleBuilds(c, ref, []string{"2", "3", "
5"}) | |
| 65 So(err, ShouldBeNil) | |
| 66 So(len(cb), ShouldEqual, 3) | |
| 67 So(len(cb[0]), ShouldEqual, 1) | |
| 68 }) | |
| 69 }) | |
| 70 } | |
| OLD | NEW |