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

Side by Side Diff: docs/present/lightning/gae_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 unified diff | Download patch
« no previous file with comments | « docs/present/lightning/dummy.go ('k') | docs/present/lightning/native_test.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 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
1 // +build !native_appengine 5 // +build !native_appengine
2 6
3 package demo 7 package demo
4 8
5 import "testing" 9 import "testing"
6 import "golang.org/x/net/context" 10 import "golang.org/x/net/context"
7 import "github.com/luci/gae/impl/memory" 11 import "github.com/luci/gae/impl/memory"
8 import . "github.com/smartystreets/goconvey/convey" 12 import . "github.com/smartystreets/goconvey/convey"
9 13
10 // START OMIT 14 // START OMIT
11 15
12 import "github.com/luci/gae/service/datastore" // HL 16 import "github.com/luci/gae/service/datastore" // HL
13 17
14 func TestGAE(t *testing.T) { 18 func TestGAE(t *testing.T) {
15 type Model struct { // HL 19 type Model struct { // HL
16 ID string `gae:"$id"` // HL 20 ID string `gae:"$id"` // HL
17 A, B int // HL 21 A, B int // HL
18 } // HL 22 } // HL
19 Convey("Put/Get w/ gae", t, func() { 23 Convey("Put/Get w/ gae", t, func() {
20 ctx := memory.Use(context.Background()) 24 ctx := memory.Use(context.Background())
21 » » ds := datastore.Get(ctx) // get datastore client 25 » » So(datastore.Put(ctx, // HL
22 » » So(ds.Put( // HL
23 &Model{"one thing", 10, 20}, // HL 26 &Model{"one thing", 10, 20}, // HL
24 &Model{"or another", 20, 30}), ShouldBeNil) // HL 27 &Model{"or another", 20, 30}), ShouldBeNil) // HL
25 ms := []*Model{{ID: "one thing"}, {ID: "or another"}} 28 ms := []*Model{{ID: "one thing"}, {ID: "or another"}}
26 » » So(ds.Get(ms), ShouldBeNil) // HL 29 » » So(datastore.Get(ctx, ms), ShouldBeNil) // HL
27 So(ms, ShouldResemble, []*Model{{"one thing", 10, 20}, {"or anot her", 20, 30}}) 30 So(ms, ShouldResemble, []*Model{{"one thing", 10, 20}, {"or anot her", 20, 30}})
28 }) 31 })
29 } 32 }
30 33
31 // END OMIT 34 // END OMIT
OLDNEW
« no previous file with comments | « docs/present/lightning/dummy.go ('k') | docs/present/lightning/native_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698