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

Side by Side Diff: docs/present/lightning/gae_test.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // +build !native_appengine 1 // +build !native_appengine
2 2
3 package demo 3 package demo
4 4
5 import "testing" 5 import "testing"
6 import "golang.org/x/net/context" 6 import "golang.org/x/net/context"
7 import "github.com/luci/gae/impl/memory" 7 import "github.com/luci/gae/impl/memory"
8 import . "github.com/smartystreets/goconvey/convey" 8 import . "github.com/smartystreets/goconvey/convey"
9 9
10 // START OMIT 10 // START OMIT
11 11
12 import "github.com/luci/gae/service/datastore" // HL 12 import "github.com/luci/gae/service/datastore" // HL
13 13
14 func TestGAE(t *testing.T) { 14 func TestGAE(t *testing.T) {
15 type Model struct { // HL 15 type Model struct { // HL
16 ID string `gae:"$id"` // HL 16 ID string `gae:"$id"` // HL
17 A, B int // HL 17 A, B int // HL
18 } // HL 18 } // HL
19 Convey("Put/Get w/ gae", t, func() { 19 Convey("Put/Get w/ gae", t, func() {
20 ctx := memory.Use(context.Background()) 20 ctx := memory.Use(context.Background())
21 » » ds := datastore.Get(ctx) // get datastore client 21 » » So(datastore.Put(ctx, // HL
22 » » So(ds.Put( // HL
23 &Model{"one thing", 10, 20}, // HL 22 &Model{"one thing", 10, 20}, // HL
24 &Model{"or another", 20, 30}), ShouldBeNil) // HL 23 &Model{"or another", 20, 30}), ShouldBeNil) // HL
25 ms := []*Model{{ID: "one thing"}, {ID: "or another"}} 24 ms := []*Model{{ID: "one thing"}, {ID: "or another"}}
26 » » So(ds.Get(ms), ShouldBeNil) // HL 25 » » So(datastore.Get(ctx, ms), ShouldBeNil) // HL
27 So(ms, ShouldResemble, []*Model{{"one thing", 10, 20}, {"or anot her", 20, 30}}) 26 So(ms, ShouldResemble, []*Model{{"one thing", 10, 20}, {"or anot her", 20, 30}})
28 }) 27 })
29 } 28 }
30 29
31 // END OMIT 30 // END OMIT
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698