| Index: milo/appengine/swarming/build_test.go
|
| diff --git a/milo/appengine/swarming/build_test.go b/milo/appengine/swarming/build_test.go
|
| index 0d81498321e06f327551b337e9eb287b48ad8ba2..b06618e82e9f701d3ffcba6a853ef4e61ab9c872 100644
|
| --- a/milo/appengine/swarming/build_test.go
|
| +++ b/milo/appengine/swarming/build_test.go
|
| @@ -15,6 +15,8 @@ import (
|
|
|
| "github.com/luci/luci-go/common/clock/testclock"
|
|
|
| + "github.com/luci/gae/impl/memory"
|
| +
|
| "golang.org/x/net/context"
|
|
|
| . "github.com/smartystreets/goconvey/convey"
|
| @@ -38,23 +40,30 @@ func shouldMatchExpectationsFor(actualContents interface{}, expectedFilename ...
|
| }
|
|
|
| func TestBuild(t *testing.T) {
|
| - c := context.Background()
|
| - c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
|
| + t.Parallel()
|
|
|
| - var svc debugSwarmingService
|
| if *generate {
|
| + c := context.Background()
|
| + c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
|
| + c = memory.Use(c)
|
| +
|
| for _, tc := range getTestCases() {
|
| + bl := buildLoader{
|
| + logDogClientFunc: logDogClientFunc(tc),
|
| + }
|
| + svc := debugSwarmingService{tc}
|
| +
|
| fmt.Printf("Generating expectations for %s\n", tc)
|
|
|
| - build, err := swarmingBuildImpl(c, svc, "foo", tc)
|
| + build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.name)
|
| if err != nil {
|
| panic(fmt.Errorf("Could not run swarmingBuildImpl for %s: %s", tc, err))
|
| }
|
| buildJSON, err := json.MarshalIndent(build, "", " ")
|
| if err != nil {
|
| - panic(fmt.Errorf("Could not JSON marshal %s: %s", tc, err))
|
| + panic(fmt.Errorf("Could not JSON marshal %s: %s", tc.name, err))
|
| }
|
| - filename := filepath.Join("expectations", tc+".json")
|
| + filename := filepath.Join("expectations", tc.name+".json")
|
| err = ioutil.WriteFile(filename, []byte(buildJSON), 0644)
|
| if err != nil {
|
| panic(fmt.Errorf("Encountered error while trying to write to %s: %s", filename, err))
|
| @@ -64,11 +73,20 @@ func TestBuild(t *testing.T) {
|
| }
|
|
|
| Convey(`A test Environment`, t, func() {
|
| + c := context.Background()
|
| + c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11, 0, 0, 0, time.UTC))
|
| + c = memory.Use(c)
|
| +
|
| for _, tc := range getTestCases() {
|
| - Convey(fmt.Sprintf("Test Case: %s", tc), func() {
|
| - build, err := swarmingBuildImpl(c, svc, "foo", tc)
|
| + Convey(fmt.Sprintf("Test Case: %s", tc.name), func() {
|
| + bl := buildLoader{
|
| + logDogClientFunc: logDogClientFunc(tc),
|
| + }
|
| + svc := debugSwarmingService{tc}
|
| +
|
| + build, err := bl.swarmingBuildImpl(c, svc, "foo", tc.name)
|
| So(err, ShouldBeNil)
|
| - So(build, shouldMatchExpectationsFor, tc+".json")
|
| + So(build, shouldMatchExpectationsFor, tc.name+".json")
|
| })
|
| }
|
| })
|
|
|