| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 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 catalog | 5 package catalog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "testing" | 9 "testing" |
| 10 | 10 |
| 11 "github.com/golang/protobuf/proto" | 11 "github.com/golang/protobuf/proto" |
| 12 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 13 "google.golang.org/api/pubsub/v1" | 13 "google.golang.org/api/pubsub/v1" |
| 14 | 14 |
| 15 "github.com/luci/luci-go/common/config" | |
| 16 memcfg "github.com/luci/luci-go/common/config/impl/memory" | 15 memcfg "github.com/luci/luci-go/common/config/impl/memory" |
| 16 "github.com/luci/luci-go/luci_config/server/cfgclient/backend/testconfig
" |
| 17 | 17 |
| 18 "github.com/luci/luci-go/scheduler/appengine/messages" | 18 "github.com/luci/luci-go/scheduler/appengine/messages" |
| 19 "github.com/luci/luci-go/scheduler/appengine/task" | 19 "github.com/luci/luci-go/scheduler/appengine/task" |
| 20 | 20 |
| 21 . "github.com/luci/luci-go/common/testing/assertions" | 21 . "github.com/luci/luci-go/common/testing/assertions" |
| 22 . "github.com/smartystreets/goconvey/convey" | 22 . "github.com/smartystreets/goconvey/convey" |
| 23 ) | 23 ) |
| 24 | 24 |
| 25 func TestRegisterTaskManagerAndFriends(t *testing.T) { | 25 func TestRegisterTaskManagerAndFriends(t *testing.T) { |
| 26 Convey("RegisterTaskManager works", t, func() { | 26 Convey("RegisterTaskManager works", t, func() { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 // Once registered, but not anymore. | 167 // Once registered, but not anymore. |
| 168 c = New("scheduler.cfg").(*catalog) | 168 c = New("scheduler.cfg").(*catalog) |
| 169 _, err = c.UnmarshalTask(blob) | 169 _, err = c.UnmarshalTask(blob) |
| 170 So(err, ShouldErrLike, "can't find a recognized task definition"
) | 170 So(err, ShouldErrLike, "can't find a recognized task definition"
) |
| 171 }) | 171 }) |
| 172 } | 172 } |
| 173 | 173 |
| 174 func TestConfigReading(t *testing.T) { | 174 func TestConfigReading(t *testing.T) { |
| 175 Convey("with mocked config", t, func() { | 175 Convey("with mocked config", t, func() { |
| 176 » » ctx := config.SetImplementation(context.Background(), memcfg.New
(mockedConfigs)) | 176 » » ctx := testconfig.WithCommonClient(context.Background(), memcfg.
New(mockedConfigs)) |
| 177 cat := New("scheduler.cfg") | 177 cat := New("scheduler.cfg") |
| 178 cat.RegisterTaskManager(fakeTaskManager{ | 178 cat.RegisterTaskManager(fakeTaskManager{ |
| 179 name: "noop", | 179 name: "noop", |
| 180 task: &messages.NoopTask{}, | 180 task: &messages.NoopTask{}, |
| 181 }) | 181 }) |
| 182 cat.RegisterTaskManager(fakeTaskManager{ | 182 cat.RegisterTaskManager(fakeTaskManager{ |
| 183 name: "url_fetch", | 183 name: "url_fetch", |
| 184 task: &messages.UrlFetchTask{}, | 184 task: &messages.UrlFetchTask{}, |
| 185 }) | 185 }) |
| 186 | 186 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 "projects/project1": { | 380 "projects/project1": { |
| 381 "scheduler.cfg": project1Cfg, | 381 "scheduler.cfg": project1Cfg, |
| 382 }, | 382 }, |
| 383 "projects/project2": { | 383 "projects/project2": { |
| 384 "scheduler.cfg": project2Cfg, | 384 "scheduler.cfg": project2Cfg, |
| 385 }, | 385 }, |
| 386 "projects/broken": { | 386 "projects/broken": { |
| 387 "scheduler.cfg": "broken!!!!111", | 387 "scheduler.cfg": "broken!!!!111", |
| 388 }, | 388 }, |
| 389 } | 389 } |
| OLD | NEW |