Chromium Code Reviews| Index: milo/appengine/buildbot/console_test.go |
| diff --git a/milo/appengine/buildbot/console_test.go b/milo/appengine/buildbot/console_test.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ab405087fdff7ab289762a3768f968780e843090 |
| --- /dev/null |
| +++ b/milo/appengine/buildbot/console_test.go |
| @@ -0,0 +1,65 @@ |
| +package buildbot |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "testing" |
| + |
| + "github.com/luci/gae/impl/memory" |
| + "github.com/luci/gae/service/datastore" |
| + "github.com/luci/luci-go/common/clock/testclock" |
| + "github.com/luci/luci-go/milo/api/resp" |
| + . "github.com/smartystreets/goconvey/convey" |
| +) |
| + |
| +func TestConsole(t *testing.T) { |
| + c := memory.UseWithAppID(context.Background(), "dev~luci-milo") |
| + c, _ = testclock.UseTime(c, testclock.TestTimeUTC) |
| + fakeTime := float64(123) |
| + fakeResult := int(0) |
| + |
| + // Seed a builder with 8 builds. |
| + for i := 1; i < 10; i++ { |
| + datastore.Put(c, &buildbotBuild{ |
| + Master: "fake", |
| + Buildername: "fake", |
| + Number: i, |
| + Internal: false, |
| + Times: []*float64{&fakeTime, &fakeTime}, |
| + Sourcestamp: &buildbotSourceStamp{ |
| + 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.
|
| + }, |
| + Results: &fakeResult, |
| + Finished: true, |
| + }) |
| + } |
| + putDSMasterJSON(c, &buildbotMaster{ |
| + Name: "fake", |
| + Builders: map[string]*buildbotBuilder{"fake": {}}, |
| + }, false) |
| + datastore.GetTestable(c).Consistent(true) |
| + datastore.GetTestable(c).AutoIndex(true) |
| + datastore.GetTestable(c).CatchupIndexes() |
| + |
| + Convey(`Console tests for buildbot`, t, func() { |
| + Convey(`Empty request`, func() { |
| + cb, err := GetConsoleBuilds(c, []resp.BuilderRef{}, []string{}) |
| + So(err, ShouldBeNil) |
| + So(cb, ShouldResemble, [][]*resp.ConsoleBuild{}) |
| + }) |
| + Convey(`Basic`, func() { |
| + ref := []resp.BuilderRef{ |
| + { |
| + Module: "buildbot", |
| + Name: "fake/fake", |
| + Category: []string{"np"}, |
| + ShortName: "np", |
| + }, |
| + } |
| + cb, err := GetConsoleBuilds(c, ref, []string{"2", "3", "5"}) |
| + So(err, ShouldBeNil) |
| + So(len(cb), ShouldEqual, 3) |
| + So(len(cb[0]), ShouldEqual, 1) |
| + }) |
| + }) |
| +} |