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 package memory | 5 package memory |
6 | 6 |
7 import ( | 7 import ( |
8 "infra/gae/libs/wrapper" | 8 "infra/gae/libs/wrapper" |
9 "infra/gae/libs/wrapper/unsafe" | 9 "infra/gae/libs/wrapper/unsafe" |
10 "testing" | 10 "testing" |
11 "time" | 11 "time" |
12 | 12 |
13 . "github.com/smartystreets/goconvey/convey" | 13 . "github.com/smartystreets/goconvey/convey" |
14 "golang.org/x/net/context" | 14 "golang.org/x/net/context" |
15 | 15 |
16 "appengine/memcache" | 16 "appengine/memcache" |
17 ) | 17 ) |
18 | 18 |
19 func TestMemcache(t *testing.T) { | 19 func TestMemcache(t *testing.T) { |
20 t.Parallel() | 20 t.Parallel() |
21 | 21 |
22 Convey("memcache", t, func() { | 22 Convey("memcache", t, func() { |
23 now := time.Now() | 23 now := time.Now() |
24 timeNow := func(context.Context) time.Time { | 24 timeNow := func(context.Context) time.Time { |
25 ret := now | 25 ret := now |
26 now = now.Add(time.Second) | 26 now = now.Add(time.Second) |
27 return ret | 27 return ret |
28 } | 28 } |
29 » » c := UseMC(UseGI(wrapper.SetTimeNowFactory(Enable(context.Backgr
ound()), timeNow))) | 29 » » c := Use(wrapper.SetTimeNowFactory(context.Background(), timeNow
)) |
30 mc := wrapper.GetMC(c) | 30 mc := wrapper.GetMC(c) |
31 mci := mc.(*memcacheImpl) | 31 mci := mc.(*memcacheImpl) |
32 | 32 |
33 Convey("implements MCSingleReadWriter", func() { | 33 Convey("implements MCSingleReadWriter", func() { |
34 Convey("Add", func() { | 34 Convey("Add", func() { |
35 itm := &memcache.Item{ | 35 itm := &memcache.Item{ |
36 Key: "sup", | 36 Key: "sup", |
37 Value: []byte("cool"), | 37 Value: []byte("cool"), |
38 Expiration: time.Second, | 38 Expiration: time.Second, |
39 } | 39 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 testItem := &memcache.Item{ | 210 testItem := &memcache.Item{ |
211 Key: "sup", | 211 Key: "sup", |
212 Value: []byte("cool"), | 212 Value: []byte("cool"), |
213 } | 213 } |
214 unsafe.MCSetCasID(testItem, 1) | 214 unsafe.MCSetCasID(testItem, 1) |
215 So(el, ShouldResemble, testItem) | 215 So(el, ShouldResemble, testItem) |
216 }) | 216 }) |
217 | 217 |
218 }) | 218 }) |
219 } | 219 } |
OLD | NEW |