Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: impl/memory/taskqueue_test.go

Issue 1494223002: Add API to allow you to get the non-transactional datastore or taskqueue. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix doc and naming Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « impl/memory/taskqueue.go ('k') | impl/prod/context.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "math/rand" 9 "math/rand"
10 "net/http" 10 "net/http"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 Convey("No other features are available, however", func( ) { 363 Convey("No other features are available, however", func( ) {
364 So(dsS.Get(c).RunInTransaction(func(c context.Co ntext) error { 364 So(dsS.Get(c).RunInTransaction(func(c context.Co ntext) error {
365 So(tqS.Get(c).Delete(t, "").Error(), Sho uldContainSubstring, "cannot DeleteMulti from a transaction") 365 So(tqS.Get(c).Delete(t, "").Error(), Sho uldContainSubstring, "cannot DeleteMulti from a transaction")
366 So(tqS.Get(c).Purge("").Error(), ShouldC ontainSubstring, "cannot Purge from a transaction") 366 So(tqS.Get(c).Purge("").Error(), ShouldC ontainSubstring, "cannot Purge from a transaction")
367 _, err := tqS.Get(c).Stats("") 367 _, err := tqS.Get(c).Stats("")
368 So(err.Error(), ShouldContainSubstring, "cannot Stats from a transaction") 368 So(err.Error(), ShouldContainSubstring, "cannot Stats from a transaction")
369 return nil 369 return nil
370 }, nil), ShouldBeNil) 370 }, nil), ShouldBeNil)
371 }) 371 })
372 372
373 Convey("can get the non-transactional taskqueue context though", func() {
374 So(dsS.Get(c).RunInTransaction(func(c context.Co ntext) error {
375 So(tqS.GetNoTxn(c).Delete(t, ""), Should BeNil)
376 So(tqS.GetNoTxn(c).Purge(""), ShouldBeNi l)
377 _, err := tqS.GetNoTxn(c).Stats("")
378 So(err, ShouldBeNil)
379 return nil
380 }, nil), ShouldBeNil)
381 })
382
373 Convey("adding a new task only happens if we don't errou t", func() { 383 Convey("adding a new task only happens if we don't errou t", func() {
374 So(dsS.Get(c).RunInTransaction(func(c context.Co ntext) error { 384 So(dsS.Get(c).RunInTransaction(func(c context.Co ntext) error {
375 t3 := tq.NewTask("/sandwitch/victory") 385 t3 := tq.NewTask("/sandwitch/victory")
376 So(tqS.Get(c).Add(t3, ""), ShouldBeNil) 386 So(tqS.Get(c).Add(t3, ""), ShouldBeNil)
377 return fmt.Errorf("nooooo") 387 return fmt.Errorf("nooooo")
378 }, nil), ShouldErrLike, "nooooo") 388 }, nil), ShouldErrLike, "nooooo")
379 389
380 So(tqt.GetScheduledTasks()["default"][t.Name], S houldResemble, t) 390 So(tqt.GetScheduledTasks()["default"][t.Name], S houldResemble, t)
381 So(tqt.GetTombstonedTasks()["default"][t2.Name], ShouldResemble, t2) 391 So(tqt.GetTombstonedTasks()["default"][t2.Name], ShouldResemble, t2)
382 So(tqt.GetTransactionTasks()["default"], ShouldB eNil) 392 So(tqt.GetTransactionTasks()["default"], ShouldB eNil)
(...skipping 12 matching lines...) Expand all
395 }() 405 }()
396 406
397 So(tqt.GetScheduledTasks()["default"][t.Name], S houldResemble, t) 407 So(tqt.GetScheduledTasks()["default"][t.Name], S houldResemble, t)
398 So(tqt.GetTombstonedTasks()["default"][t2.Name], ShouldResemble, t2) 408 So(tqt.GetTombstonedTasks()["default"][t2.Name], ShouldResemble, t2)
399 So(tqt.GetTransactionTasks()["default"], ShouldB eNil) 409 So(tqt.GetTransactionTasks()["default"], ShouldB eNil)
400 }) 410 })
401 411
402 }) 412 })
403 }) 413 })
404 } 414 }
OLDNEW
« no previous file with comments | « impl/memory/taskqueue.go ('k') | impl/prod/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698