| OLD | NEW |
| 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 |
| OLD | NEW |