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

Unified Diff: impl/memory/race_test.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Lightning talk licenses. Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/module_test.go ('k') | impl/memory/taskqueue.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/race_test.go
diff --git a/impl/memory/race_test.go b/impl/memory/race_test.go
index 79eb5c4e04b2d33903799a3eece83c5d36437e9a..caa6d798ec59d3d22b508dc71dea62c94e597d0b 100644
--- a/impl/memory/race_test.go
+++ b/impl/memory/race_test.go
@@ -9,7 +9,8 @@ import (
"sync/atomic"
"testing"
- "github.com/luci/gae/service/datastore"
+ ds "github.com/luci/gae/service/datastore"
+
"golang.org/x/net/context"
)
@@ -19,7 +20,7 @@ func TestRaceGetPut(t *testing.T) {
value := int32(0)
num := int32(0)
- ds := datastore.Get(Use(context.Background()))
+ c := Use(context.Background())
wg := sync.WaitGroup{}
@@ -28,13 +29,11 @@ func TestRaceGetPut(t *testing.T) {
go func() {
defer wg.Done()
- err := ds.RunInTransaction(func(c context.Context) error {
+ err := ds.RunInTransaction(c, func(c context.Context) error {
atomic.AddInt32(&num, 1)
- ds := datastore.Get(c)
-
- obj := pmap("$key", ds.MakeKey("Obj", 1))
- if err := ds.Get(obj); err != nil && err != datastore.ErrNoSuchEntity {
+ obj := pmap("$key", ds.MakeKey(c, "Obj", 1))
+ if err := ds.Get(c, obj); err != nil && err != ds.ErrNoSuchEntity {
t.Fatal("error get", err)
}
cur := int64(0)
@@ -45,8 +44,8 @@ func TestRaceGetPut(t *testing.T) {
cur++
obj["Value"] = prop(cur)
- return ds.Put(obj)
- }, &datastore.TransactionOptions{Attempts: 200})
+ return ds.Put(c, obj)
+ }, &ds.TransactionOptions{Attempts: 200})
if err != nil {
t.Fatal("error during transaction", err)
@@ -57,8 +56,8 @@ func TestRaceGetPut(t *testing.T) {
}
wg.Wait()
- obj := pmap("$key", ds.MakeKey("Obj", 1))
- if ds.Get(obj) != nil {
+ obj := pmap("$key", ds.MakeKey(c, "Obj", 1))
+ if ds.Get(c, obj) != nil {
t.FailNow()
}
t.Logf("Ran %d inner functions", num)
@@ -70,7 +69,7 @@ func TestRaceGetPut(t *testing.T) {
func TestRaceNonConflictingPuts(t *testing.T) {
t.Parallel()
- ds := datastore.Get(Use(context.Background()))
+ c := Use(context.Background())
num := int32(0)
@@ -81,9 +80,8 @@ func TestRaceNonConflictingPuts(t *testing.T) {
go func() {
defer wg.Done()
- err := ds.RunInTransaction(func(c context.Context) error {
- ds := datastore.Get(c)
- return ds.Put(pmap(
+ err := ds.RunInTransaction(c, func(c context.Context) error {
+ return ds.Put(c, pmap(
"$kind", "Thing", Next,
"Value", 100))
}, nil)
« no previous file with comments | « impl/memory/module_test.go ('k') | impl/memory/taskqueue.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698