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