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

Unified Diff: milo/appengine/buildbot/console_test.go

Issue 2856273004: Milo: Increase test coverage for appengine/buildbot (Closed)
Patch Set: review Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
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..24e6461a9a166ab3ed2b36f2789123a0d4f6ecf7
--- /dev/null
+++ b/milo/appengine/buildbot/console_test.go
@@ -0,0 +1,70 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package buildbot
+
+import (
+ "context"
+ "strconv"
+ "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: strconv.Itoa(i),
+ },
+ 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)
+ })
+ })
+}
« no previous file with comments | « milo/appengine/buildbot/buildinfo_test.go ('k') | milo/appengine/buildbot/expectations/chromium_presubmit.426944.build.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698