| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 So(tq.Add(c, "", tasks...), ShouldBeNil) | 349 So(tq.Add(c, "", tasks...), ShouldBeNil) |
| 350 So(len(tqt.GetScheduledTasks()["default"
]), ShouldEqual, 1) | 350 So(len(tqt.GetScheduledTasks()["default"
]), ShouldEqual, 1) |
| 351 So(len(tqt.GetTransactionTasks()["defaul
t"]), ShouldEqual, 3) | 351 So(len(tqt.GetTransactionTasks()["defaul
t"]), ShouldEqual, 3) |
| 352 return nil | 352 return nil |
| 353 }, nil), ShouldBeNil) | 353 }, nil), ShouldBeNil) |
| 354 So(len(tqt.GetScheduledTasks()["default"]), Shou
ldEqual, 4) | 354 So(len(tqt.GetScheduledTasks()["default"]), Shou
ldEqual, 4) |
| 355 So(len(tqt.GetTransactionTasks()["default"]), Sh
ouldEqual, 0) | 355 So(len(tqt.GetTransactionTasks()["default"]), Sh
ouldEqual, 0) |
| 356 }) | 356 }) |
| 357 | 357 |
| 358 Convey("unless you add too many things", func() { | 358 Convey("unless you add too many things", func() { |
| 359 t.Name = "" |
| 360 |
| 359 So(ds.RunInTransaction(c, func(c context.Context
) error { | 361 So(ds.RunInTransaction(c, func(c context.Context
) error { |
| 360 for i := 0; i < 5; i++ { | 362 for i := 0; i < 5; i++ { |
| 361 So(tq.Add(c, "", t.Duplicate()),
ShouldBeNil) | 363 So(tq.Add(c, "", t.Duplicate()),
ShouldBeNil) |
| 362 } | 364 } |
| 363 So(tq.Add(c, "", t).Error(), ShouldConta
inSubstring, "BAD_REQUEST") | 365 So(tq.Add(c, "", t).Error(), ShouldConta
inSubstring, "BAD_REQUEST") |
| 364 return nil | 366 return nil |
| 365 }, nil), ShouldBeNil) | 367 }, nil), ShouldBeNil) |
| 366 }) | 368 }) |
| 367 | 369 |
| 368 Convey("unless you Add to a bad queue", func() { | 370 Convey("unless you Add to a bad queue", func() { |
| 371 t.Name = "" |
| 372 |
| 369 So(ds.RunInTransaction(c, func(c context.Context
) error { | 373 So(ds.RunInTransaction(c, func(c context.Context
) error { |
| 370 So(tq.Add(c, "meat", t).Error(), ShouldC
ontainSubstring, "UNKNOWN_QUEUE") | 374 So(tq.Add(c, "meat", t).Error(), ShouldC
ontainSubstring, "UNKNOWN_QUEUE") |
| 371 | 375 |
| 372 Convey("unless you add it!", func() { | 376 Convey("unless you add it!", func() { |
| 373 tq.Raw(c).GetTestable().CreateQu
eue("meat") | 377 tq.Raw(c).GetTestable().CreateQu
eue("meat") |
| 374 So(tq.Add(c, "meat", t), ShouldB
eNil) | 378 So(tq.Add(c, "meat", t), ShouldB
eNil) |
| 375 }) | 379 }) |
| 376 | 380 |
| 377 return nil | 381 return nil |
| 378 }, nil), ShouldBeNil) | 382 }, nil), ShouldBeNil) |
| 379 }) | 383 }) |
| 380 | 384 |
| 385 Convey("unless the task is named", func() { |
| 386 So(ds.RunInTransaction(c, func(c context.Context
) error { |
| 387 err := tq.Add(c, "", t) // Note: "t" has
a Name from initial Add. |
| 388 So(err, ShouldNotBeNil) |
| 389 So(err.Error(), ShouldContainSubstring,
"INVALID_TASK_NAME") |
| 390 |
| 391 return nil |
| 392 }, nil), ShouldBeNil) |
| 393 }) |
| 394 |
| 381 Convey("No other features are available, however", func(
) { | 395 Convey("No other features are available, however", func(
) { |
| 382 So(ds.RunInTransaction(c, func(c context.Context
) error { | 396 So(ds.RunInTransaction(c, func(c context.Context
) error { |
| 383 So(tq.Delete(c, "", t).Error(), ShouldCo
ntainSubstring, "cannot DeleteMulti from a transaction") | 397 So(tq.Delete(c, "", t).Error(), ShouldCo
ntainSubstring, "cannot DeleteMulti from a transaction") |
| 384 So(tq.Purge(c, "").Error(), ShouldContai
nSubstring, "cannot Purge from a transaction") | 398 So(tq.Purge(c, "").Error(), ShouldContai
nSubstring, "cannot Purge from a transaction") |
| 385 _, err := tq.Stats(c, "") | 399 _, err := tq.Stats(c, "") |
| 386 So(err.Error(), ShouldContainSubstring,
"cannot Stats from a transaction") | 400 So(err.Error(), ShouldContainSubstring,
"cannot Stats from a transaction") |
| 387 return nil | 401 return nil |
| 388 }, nil), ShouldBeNil) | 402 }, nil), ShouldBeNil) |
| 389 }) | 403 }) |
| 390 | 404 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 leased, err := tq.LeaseByTag(c, 100, "pull", tim
e.Minute, "") | 979 leased, err := tq.LeaseByTag(c, 100, "pull", tim
e.Minute, "") |
| 966 So(err, ShouldBeNil) | 980 So(err, ShouldBeNil) |
| 967 So(len(leased), ShouldEqual, 5) | 981 So(len(leased), ShouldEqual, 5) |
| 968 for i := 0; i < 5; i++ { | 982 for i := 0; i < 5; i++ { |
| 969 So(leased[i].Name, ShouldEqual, fmt.Spri
ntf("task-%d", i)) | 983 So(leased[i].Name, ShouldEqual, fmt.Spri
ntf("task-%d", i)) |
| 970 } | 984 } |
| 971 }) | 985 }) |
| 972 }) | 986 }) |
| 973 }) | 987 }) |
| 974 } | 988 } |
| OLD | NEW |