| 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" |
| 11 "io/ioutil" | 11 "io/ioutil" |
| 12 "os" | 12 "os" |
| 13 "path/filepath" | 13 "path/filepath" |
| 14 "testing" | 14 "testing" |
| 15 "time" | |
| 16 | 15 |
| 17 "github.com/luci/gae/impl/memory" | 16 "github.com/luci/gae/impl/memory" |
| 18 "github.com/luci/luci-go/common/clock/testclock" | 17 "github.com/luci/luci-go/common/clock/testclock" |
| 19 memcfg "github.com/luci/luci-go/common/config/impl/memory" | 18 memcfg "github.com/luci/luci-go/common/config/impl/memory" |
| 20 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig
" | 19 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig
" |
| 21 "github.com/luci/luci-go/milo/appengine/common" | 20 "github.com/luci/luci-go/milo/appengine/common" |
| 22 "golang.org/x/net/context" | 21 "golang.org/x/net/context" |
| 23 | 22 |
| 24 . "github.com/smartystreets/goconvey/convey" | 23 . "github.com/smartystreets/goconvey/convey" |
| 25 ) | 24 ) |
| 26 | 25 |
| 27 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") | 26 var generate = flag.Bool("test.generate", false, "Generate expectations instead
of running tests.") |
| 28 | 27 |
| 29 func TestBuilder(t *testing.T) { | 28 func TestBuilder(t *testing.T) { |
| 30 t.Parallel() | 29 t.Parallel() |
| 31 | 30 |
| 32 testCases := []struct{ bucket, builder string }{ | 31 testCases := []struct{ bucket, builder string }{ |
| 33 {"master.tryserver.infra", "InfraPresubmit"}, | 32 {"master.tryserver.infra", "InfraPresubmit"}, |
| 34 {"master.tryserver.infra", "InfraPresubmit.Swarming"}, | 33 {"master.tryserver.infra", "InfraPresubmit.Swarming"}, |
| 35 } | 34 } |
| 36 | 35 |
| 37 Convey("Builder", t, func() { | 36 Convey("Builder", t, func() { |
| 38 c := memory.UseWithAppID(context.Background(), "luci-milo-dev") | 37 c := memory.UseWithAppID(context.Background(), "luci-milo-dev") |
| 39 » » c, _ = testclock.UseTime(c, time.Date(2016, time.March, 14, 11,
0, 0, 0, time.UTC)) | 38 » » c, _ = testclock.UseTime(c, testclock.TestRecentTimeUTC) |
| 40 c = testconfig.WithCommonClient(c, memcfg.New(bktConfigFull)) | 39 c = testconfig.WithCommonClient(c, memcfg.New(bktConfigFull)) |
| 41 // Update the service config so that the settings are loaded. | 40 // Update the service config so that the settings are loaded. |
| 42 err := common.UpdateServiceConfig(c) | 41 err := common.UpdateServiceConfig(c) |
| 43 So(err, ShouldBeNil) | 42 So(err, ShouldBeNil) |
| 44 | 43 |
| 45 for _, tc := range testCases { | 44 for _, tc := range testCases { |
| 46 tc := tc | 45 tc := tc |
| 47 Convey(fmt.Sprintf("%s:%s", tc.bucket, tc.builder), func
() { | 46 Convey(fmt.Sprintf("%s:%s", tc.bucket, tc.builder), func
() { |
| 48 expectationFilePath := filepath.Join("expectatio
ns", tc.bucket, tc.builder+".json") | 47 expectationFilePath := filepath.Join("expectatio
ns", tc.bucket, tc.builder+".json") |
| 49 err := os.MkdirAll(filepath.Dir(expectationFileP
ath), 0777) | 48 err := os.MkdirAll(filepath.Dir(expectationFileP
ath), 0777) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 76 buildbucket: { | 75 buildbucket: { |
| 77 host: "debug" | 76 host: "debug" |
| 78 } | 77 } |
| 79 ` | 78 ` |
| 80 | 79 |
| 81 var bktConfigFull = map[string]memcfg.ConfigSet{ | 80 var bktConfigFull = map[string]memcfg.ConfigSet{ |
| 82 "services/luci-milo-dev": { | 81 "services/luci-milo-dev": { |
| 83 "settings.cfg": bktConfig, | 82 "settings.cfg": bktConfig, |
| 84 }, | 83 }, |
| 85 } | 84 } |
| OLD | NEW |