| 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 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 c := context.Background() | 34 c := context.Background() |
| 35 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11,
0, 0, 0, time.UTC)) | 35 c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11,
0, 0, 0, time.UTC)) |
| 36 | 36 |
| 37 for _, tc := range testCases { | 37 for _, tc := range testCases { |
| 38 tc := tc | 38 tc := tc |
| 39 Convey(fmt.Sprintf("%s:%s", tc.bucket, tc.builder), func
() { | 39 Convey(fmt.Sprintf("%s:%s", tc.bucket, tc.builder), func
() { |
| 40 expectationFilePath := filepath.Join("expectatio
ns", tc.bucket, tc.builder+".json") | 40 expectationFilePath := filepath.Join("expectatio
ns", tc.bucket, tc.builder+".json") |
| 41 err := os.MkdirAll(filepath.Dir(expectationFileP
ath), 0777) | 41 err := os.MkdirAll(filepath.Dir(expectationFileP
ath), 0777) |
| 42 So(err, ShouldBeNil) | 42 So(err, ShouldBeNil) |
| 43 | 43 |
| 44 » » » » actual, err := builderImpl(c, "debug", tc.bucket
, tc.builder, 0) | 44 » » » » actual, err := builderImpl(c, |
| 45 » » » » » builderQuery{ |
| 46 » » » » » » Server: "debug", |
| 47 » » » » » » Bucket: tc.bucket, |
| 48 » » » » » » Builder: tc.builder, |
| 49 » » » » » » Limit: 0, |
| 50 » » » » » }) |
| 45 So(err, ShouldBeNil) | 51 So(err, ShouldBeNil) |
| 46 actualJSON, err := json.MarshalIndent(actual, ""
, " ") | 52 actualJSON, err := json.MarshalIndent(actual, ""
, " ") |
| 47 So(err, ShouldBeNil) | 53 So(err, ShouldBeNil) |
| 48 | 54 |
| 49 if *generate { | 55 if *generate { |
| 50 err := ioutil.WriteFile(expectationFileP
ath, actualJSON, 0777) | 56 err := ioutil.WriteFile(expectationFileP
ath, actualJSON, 0777) |
| 51 So(err, ShouldBeNil) | 57 So(err, ShouldBeNil) |
| 52 } else { | 58 } else { |
| 53 expectedJSON, err := ioutil.ReadFile(exp
ectationFilePath) | 59 expectedJSON, err := ioutil.ReadFile(exp
ectationFilePath) |
| 54 So(err, ShouldBeNil) | 60 So(err, ShouldBeNil) |
| 55 So(string(actualJSON), ShouldEqual, stri
ng(expectedJSON)) | 61 So(string(actualJSON), ShouldEqual, stri
ng(expectedJSON)) |
| 56 } | 62 } |
| 57 }) | 63 }) |
| 58 } | 64 } |
| 59 }) | 65 }) |
| 60 } | 66 } |
| OLD | NEW |