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

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

Issue 2856273004: Milo: Increase test coverage for appengine/buildbot (Closed)
Patch Set: Imports, headers 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/builder.go
diff --git a/milo/appengine/buildbot/builder.go b/milo/appengine/buildbot/builder.go
index b89682a45e450c66ea6f93037d5009f836b58b4e..ba9a4d4f46948fc4ae303a291e82f4f18b2beb8a 100644
--- a/milo/appengine/buildbot/builder.go
+++ b/milo/appengine/buildbot/builder.go
@@ -152,6 +152,18 @@ var errMasterNotFound = errors.New(
"Either the request resource was not found or you have insufficient permissions")
var errNotAuth = errors.New("You are not authenticated, try logging in")
+type errBuilderNotFound struct {
+ master string
+ builder string
+ available []string
+}
+
+func (e errBuilderNotFound) Error() string {
+ avail := strings.Join(e.available, "\n")
+ return fmt.Sprintf("Cannot find builder %q in master %q.\nAvailable builders: \n%q",
nodir 2017/05/26 18:33:04 i think the list of builders should be %s, otherwi
Ryan Tseng 2017/05/26 22:49:22 Done.
+ e.master, e.builder, avail)
nodir 2017/05/26 18:33:04 swap e.master and e.builder, see order in the form
Ryan Tseng 2017/05/26 22:49:22 Shoot I'm blind, I even checked for this.
+}
+
// builderImpl is the implementation for getting a milo builder page from buildbot.
// This gets:
// * Current Builds from querying the master json from the datastore.
@@ -192,10 +204,7 @@ func builderImpl(
keys = append(keys, k)
}
sort.Strings(keys)
- avail := strings.Join(keys, "\n")
- return nil, fmt.Errorf(
- "Cannot find builder %s in master %s.\nAvailable builders: \n%s",
- builderName, masterName, avail)
+ return nil, errBuilderNotFound{masterName, builderName, keys}
}
// Extract pending builds out of the master json.
result.PendingBuilds = make([]*resp.BuildSummary, len(p.PendingBuildStates))

Powered by Google App Engine
This is Rietveld 408576698