| OLD | NEW |
| 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 txnBuf | 5 package txnBuf |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "fmt" | 9 "fmt" |
| 10 "math/rand" | 10 "math/rand" |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 So(vals, ShouldResemble, []*Foo{foo1, projectDat
a[0], foo7}) | 849 So(vals, ShouldResemble, []*Foo{foo1, projectDat
a[0], foo7}) |
| 850 | 850 |
| 851 }) | 851 }) |
| 852 | 852 |
| 853 Convey("start transaction from inside query", func() { | 853 Convey("start transaction from inside query", func() { |
| 854 _, _, ds := mkds(projectData) | 854 _, _, ds := mkds(projectData) |
| 855 So(ds.RunInTransaction(func(c context.Context) e
rror { | 855 So(ds.RunInTransaction(func(c context.Context) e
rror { |
| 856 ds := datastore.Get(c) | 856 ds := datastore.Get(c) |
| 857 | 857 |
| 858 q := datastore.NewQuery("Foo").Ancestor(
root) | 858 q := datastore.NewQuery("Foo").Ancestor(
root) |
| 859 » » » » » return ds.Run(q, func(pm datastore.Prope
rtyMap, _ datastore.CursorCB) bool { | 859 » » » » » return ds.Run(q, func(pm datastore.Prope
rtyMap) { |
| 860 So(ds.RunInTransaction(func(c co
ntext.Context) error { | 860 So(ds.RunInTransaction(func(c co
ntext.Context) error { |
| 861 ds := datastore.Get(c) | 861 ds := datastore.Get(c) |
| 862 pm["Value"] = append(pm[
"Value"], datastore.MkProperty("wat")) | 862 pm["Value"] = append(pm[
"Value"], datastore.MkProperty("wat")) |
| 863 return ds.Put(pm) | 863 return ds.Put(pm) |
| 864 }, nil), ShouldBeNil) | 864 }, nil), ShouldBeNil) |
| 865 return true | |
| 866 }) | 865 }) |
| 867 }, &datastore.TransactionOptions{XG: true}), Sho
uldBeNil) | 866 }, &datastore.TransactionOptions{XG: true}), Sho
uldBeNil) |
| 868 | 867 |
| 869 » » » » So(ds.Run(datastore.NewQuery("Foo"), func(pm dat
astore.PropertyMap, _ datastore.CursorCB) bool { | 868 » » » » So(ds.Run(datastore.NewQuery("Foo"), func(pm dat
astore.PropertyMap) { |
| 870 val := pm["Value"] | 869 val := pm["Value"] |
| 871 So(val[len(val)-1].Value(), ShouldResemb
le, "wat") | 870 So(val[len(val)-1].Value(), ShouldResemb
le, "wat") |
| 872 return true | |
| 873 }), ShouldBeNil) | 871 }), ShouldBeNil) |
| 874 }) | 872 }) |
| 875 | 873 |
| 876 }) | 874 }) |
| 877 | 875 |
| 878 }) | 876 }) |
| 879 | 877 |
| 880 } | 878 } |
| OLD | NEW |