| 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 // +build appengine | 5 // +build appengine |
| 6 | 6 |
| 7 package prod | 7 package prod |
| 8 | 8 |
| 9 import ( | 9 import ( |
| 10 "testing" | 10 "testing" |
| 11 "time" | 11 "time" |
| 12 | 12 |
| 13 "github.com/luci/gae/service/blobstore" | 13 "github.com/luci/gae/service/blobstore" |
| 14 "github.com/luci/gae/service/datastore" | 14 "github.com/luci/gae/service/datastore" |
| 15 "github.com/luci/gae/service/info" | 15 "github.com/luci/gae/service/info" |
| 16 "github.com/luci/luci-go/common/logging" |
| 16 . "github.com/smartystreets/goconvey/convey" | 17 . "github.com/smartystreets/goconvey/convey" |
| 17 "golang.org/x/net/context" | 18 "golang.org/x/net/context" |
| 18 "google.golang.org/appengine/aetest" | 19 "google.golang.org/appengine/aetest" |
| 19 ) | 20 ) |
| 20 | 21 |
| 21 var ( | 22 var ( |
| 22 mp = datastore.MkProperty | 23 mp = datastore.MkProperty |
| 23 mpNI = datastore.MkPropertyNI | 24 mpNI = datastore.MkPropertyNI |
| 24 ) | 25 ) |
| 25 | 26 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 So(err, ShouldBeNil) | 47 So(err, ShouldBeNil) |
| 47 defer inst.Close() | 48 defer inst.Close() |
| 48 | 49 |
| 49 req, err := inst.NewRequest("GET", "/", nil) | 50 req, err := inst.NewRequest("GET", "/", nil) |
| 50 So(err, ShouldBeNil) | 51 So(err, ShouldBeNil) |
| 51 | 52 |
| 52 ctx := Use(context.Background(), req) | 53 ctx := Use(context.Background(), req) |
| 53 ds := datastore.Get(ctx) | 54 ds := datastore.Get(ctx) |
| 54 inf := info.Get(ctx) | 55 inf := info.Get(ctx) |
| 55 | 56 |
| 57 // You have to visually confirm that this actually happens in th
e stdout |
| 58 // of the test... yeah I know. |
| 59 logging.Infof(ctx, "I am a banana") |
| 60 |
| 56 Convey("Can probe/change Namespace", func() { | 61 Convey("Can probe/change Namespace", func() { |
| 57 So(inf.GetNamespace(), ShouldEqual, "") | 62 So(inf.GetNamespace(), ShouldEqual, "") |
| 58 ctx, err = inf.Namespace("wat") | 63 ctx, err = inf.Namespace("wat") |
| 59 So(err, ShouldBeNil) | 64 So(err, ShouldBeNil) |
| 60 inf = info.Get(ctx) | 65 inf = info.Get(ctx) |
| 61 So(inf.GetNamespace(), ShouldEqual, "wat") | 66 So(inf.GetNamespace(), ShouldEqual, "wat") |
| 62 ds = datastore.Get(ctx) | 67 ds = datastore.Get(ctx) |
| 63 So(ds.MakeKey("Hello", "world").Namespace(), ShouldEqual
, "wat") | 68 So(ds.MakeKey("Hello", "world").Namespace(), ShouldEqual
, "wat") |
| 64 }) | 69 }) |
| 65 | 70 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 So(tval, ShouldResemble, pm["Time"][0].Value()) | 210 So(tval, ShouldResemble, pm["Time"][0].Value()) |
| 206 | 211 |
| 207 ent := datastore.PropertyMap{ | 212 ent := datastore.PropertyMap{ |
| 208 "$key": {mpNI(ds.MakeKey("Something", "value"))}
, | 213 "$key": {mpNI(ds.MakeKey("Something", "value"))}
, |
| 209 } | 214 } |
| 210 So(ds.Get(&ent), ShouldBeNil) | 215 So(ds.Get(&ent), ShouldBeNil) |
| 211 So(ent["Time"], ShouldResemble, pm["Time"]) | 216 So(ent["Time"], ShouldResemble, pm["Time"]) |
| 212 }) | 217 }) |
| 213 }) | 218 }) |
| 214 } | 219 } |
| OLD | NEW |