OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package buildbucket | 5 package buildbucket |
6 | 6 |
7 import ( | 7 import ( |
8 "encoding/json" | 8 "encoding/json" |
9 "fmt" | 9 "fmt" |
10 "net/url" | 10 "net/url" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 if strings.HasSuffix(beforeBuildNumber, pattern) && err
== nil { | 176 if strings.HasSuffix(beforeBuildNumber, pattern) && err
== nil { |
177 result.Link.Label = buildNumberStr | 177 result.Link.Label = buildNumberStr |
178 } | 178 } |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 return result | 182 return result |
183 } | 183 } |
184 | 184 |
185 func getDebugBuilds(c context.Context, bucket, builder string, maxCompletedBuild
s int, target *resp.Builder) error { | 185 func getDebugBuilds(c context.Context, bucket, builder string, maxCompletedBuild
s int, target *resp.Builder) error { |
186 » resFile, err := os.Open(filepath.Join("testdata", "buildbucket", bucket,
builder+".json")) | 186 » // ../buildbucket below assumes that |
| 187 » // - this code is not executed by tests outside of this dir |
| 188 » // - this dir is a sibling of frontend dir |
| 189 » resFile, err := os.Open(filepath.Join("..", "buildbucket", "testdata", b
ucket, builder+".json")) |
187 if err != nil { | 190 if err != nil { |
188 return err | 191 return err |
189 } | 192 } |
190 defer resFile.Close() | 193 defer resFile.Close() |
191 | 194 |
192 res := &buildbucket.ApiSearchResponseMessage{} | 195 res := &buildbucket.ApiSearchResponseMessage{} |
193 if err := json.NewDecoder(resFile).Decode(res); err != nil { | 196 if err := json.NewDecoder(resFile).Decode(res); err != nil { |
194 return err | 197 return err |
195 } | 198 } |
196 | 199 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC() | 272 return time.Unix(microseconds/1e6, microseconds%1e6*1000).UTC() |
270 } | 273 } |
271 | 274 |
272 type newBuildsFirst []*resp.BuildSummary | 275 type newBuildsFirst []*resp.BuildSummary |
273 | 276 |
274 func (a newBuildsFirst) Len() int { return len(a) } | 277 func (a newBuildsFirst) Len() int { return len(a) } |
275 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | 278 func (a newBuildsFirst) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
276 func (a newBuildsFirst) Less(i, j int) bool { | 279 func (a newBuildsFirst) Less(i, j int) bool { |
277 return a[i].PendingTime.Started.After(a[j].PendingTime.Started) | 280 return a[i].PendingTime.Started.After(a[j].PendingTime.Started) |
278 } | 281 } |
OLD | NEW |