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

Side by Side Diff: impl/prod/everything_test.go

Issue 1541183002: Make setting a Memcache Item with a nil Value OK (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 4 years, 12 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 | « impl/memory/memcache_test.go ('k') | impl/prod/memcache.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"
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/gae/service/memcache"
16 "github.com/luci/luci-go/common/logging" 17 "github.com/luci/luci-go/common/logging"
17 . "github.com/smartystreets/goconvey/convey" 18 . "github.com/smartystreets/goconvey/convey"
18 "golang.org/x/net/context" 19 "golang.org/x/net/context"
19 "google.golang.org/appengine/aetest" 20 "google.golang.org/appengine/aetest"
20 ) 21 )
21 22
22 var ( 23 var (
23 mp = datastore.MkProperty 24 mp = datastore.MkProperty
24 mpNI = datastore.MkPropertyNI 25 mpNI = datastore.MkPropertyNI
25 ) 26 )
(...skipping 19 matching lines...) Expand all
45 StronglyConsistentDatastore: true, 46 StronglyConsistentDatastore: true,
46 }) 47 })
47 So(err, ShouldBeNil) 48 So(err, ShouldBeNil)
48 defer inst.Close() 49 defer inst.Close()
49 50
50 req, err := inst.NewRequest("GET", "/", nil) 51 req, err := inst.NewRequest("GET", "/", nil)
51 So(err, ShouldBeNil) 52 So(err, ShouldBeNil)
52 53
53 ctx := Use(context.Background(), req) 54 ctx := Use(context.Background(), req)
54 ds := datastore.Get(ctx) 55 ds := datastore.Get(ctx)
56 mc := memcache.Get(ctx)
55 inf := info.Get(ctx) 57 inf := info.Get(ctx)
56 58
57 // You have to visually confirm that this actually happens in th e stdout 59 // You have to visually confirm that this actually happens in th e stdout
58 // of the test... yeah I know. 60 // of the test... yeah I know.
59 logging.Infof(ctx, "I am a banana") 61 logging.Infof(ctx, "I am a banana")
60 62
61 Convey("Can probe/change Namespace", func() { 63 Convey("Can probe/change Namespace", func() {
62 So(inf.GetNamespace(), ShouldEqual, "") 64 So(inf.GetNamespace(), ShouldEqual, "")
63 ctx, err = inf.Namespace("wat") 65 ctx, err = inf.Namespace("wat")
64 So(err, ShouldBeNil) 66 So(err, ShouldBeNil)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 tval, err = all[1]["Time"][0].Project(datastore.PTTime) 209 tval, err = all[1]["Time"][0].Project(datastore.PTTime)
208 So(err, ShouldBeNil) 210 So(err, ShouldBeNil)
209 So(tval, ShouldResemble, pm["Time"][0].Value()) 211 So(tval, ShouldResemble, pm["Time"][0].Value())
210 212
211 ent := datastore.PropertyMap{ 213 ent := datastore.PropertyMap{
212 "$key": {mpNI(ds.MakeKey("Something", "value"))} , 214 "$key": {mpNI(ds.MakeKey("Something", "value"))} ,
213 } 215 }
214 So(ds.Get(&ent), ShouldBeNil) 216 So(ds.Get(&ent), ShouldBeNil)
215 So(ent["Time"], ShouldResemble, pm["Time"]) 217 So(ent["Time"], ShouldResemble, pm["Time"])
216 }) 218 })
219
220 Convey("memcache: Set (nil) is the same as Set ([]byte{})", func () {
221 So(mc.Set(mc.NewItem("bob")), ShouldBeNil) // normally w ould panic because Value is nil
222
223 bob, err := mc.Get("bob")
224 So(err, ShouldBeNil)
225 So(bob.Value(), ShouldResemble, []byte{})
226 })
217 }) 227 })
218 } 228 }
OLDNEW
« no previous file with comments | « impl/memory/memcache_test.go ('k') | impl/prod/memcache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698