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

Side by Side Diff: impl/prod/everything_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/prod/context.go ('k') | impl/prod/raw_datastore.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 // +build appengine 5 // +build appengine
6 6
7 package prod 7 package prod
8 8
9 import ( 9 import (
10 "testing" 10 "testing"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Convey("Can probe/change Namespace", func() { 56 Convey("Can probe/change Namespace", func() {
57 So(inf.GetNamespace(), ShouldEqual, "") 57 So(inf.GetNamespace(), ShouldEqual, "")
58 ctx, err = inf.Namespace("wat") 58 ctx, err = inf.Namespace("wat")
59 So(err, ShouldBeNil) 59 So(err, ShouldBeNil)
60 inf = info.Get(ctx) 60 inf = info.Get(ctx)
61 So(inf.GetNamespace(), ShouldEqual, "wat") 61 So(inf.GetNamespace(), ShouldEqual, "wat")
62 ds = datastore.Get(ctx) 62 ds = datastore.Get(ctx)
63 So(ds.MakeKey("Hello", "world").Namespace(), ShouldEqual , "wat") 63 So(ds.MakeKey("Hello", "world").Namespace(), ShouldEqual , "wat")
64 }) 64 })
65 65
66 Convey("Can get non-transactional context", func() {
67 ctx, err := inf.Namespace("foo")
68 So(err, ShouldBeNil)
69 ds = datastore.Get(ctx)
70 inf = info.Get(ctx)
71
72 ds.RunInTransaction(func(ctx context.Context) error {
73 So(ds.MakeKey("Foo", "bar").Namespace(), ShouldE qual, "foo")
74
75 So(ds.Put(&TestStruct{ValueI: []int64{100}}), Sh ouldBeNil)
76
77 err = datastore.GetNoTxn(ctx).RunInTransaction(f unc(ctx context.Context) error {
78 ds = datastore.Get(ctx)
79 So(ds.MakeKey("Foo", "bar").Namespace(), ShouldEqual, "foo")
80 So(ds.Put(&TestStruct{ValueI: []int64{10 0}}), ShouldBeNil)
81 return nil
82 }, nil)
83 So(err, ShouldBeNil)
84
85 return nil
86 }, nil)
87 })
88
66 Convey("Can Put/Get", func() { 89 Convey("Can Put/Get", func() {
67 orig := TestStruct{ 90 orig := TestStruct{
68 ValueI: []int64{1, 7, 946688461000000, 996688461 000000}, 91 ValueI: []int64{1, 7, 946688461000000, 996688461 000000},
69 ValueB: []bool{true, false}, 92 ValueB: []bool{true, false},
70 ValueS: []string{"hello", "world"}, 93 ValueS: []string{"hello", "world"},
71 ValueF: []float64{1.0, 7.0, 946688461000000.0, 9 96688461000000.0}, 94 ValueF: []float64{1.0, 7.0, 946688461000000.0, 9 96688461000000.0},
72 ValueBS: [][]byte{ 95 ValueBS: [][]byte{
73 []byte("allo"), 96 []byte("allo"),
74 []byte("hello"), 97 []byte("hello"),
75 []byte("world"), 98 []byte("world"),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 So(tval, ShouldResemble, pm["Time"][0].Value()) 205 So(tval, ShouldResemble, pm["Time"][0].Value())
183 206
184 ent := datastore.PropertyMap{ 207 ent := datastore.PropertyMap{
185 "$key": {mpNI(ds.MakeKey("Something", "value"))} , 208 "$key": {mpNI(ds.MakeKey("Something", "value"))} ,
186 } 209 }
187 So(ds.Get(&ent), ShouldBeNil) 210 So(ds.Get(&ent), ShouldBeNil)
188 So(ent["Time"], ShouldResemble, pm["Time"]) 211 So(ent["Time"], ShouldResemble, pm["Time"])
189 }) 212 })
190 }) 213 })
191 } 214 }
OLDNEW
« no previous file with comments | « impl/prod/context.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698