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" |
(...skipping 10 matching lines...) Expand all Loading... |
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 := Use(wrapper.SetTimeNowFactory(context.Background(), 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 := wrapper.GetMC(c).(*memcacheImpl) |
| 32 » » So(mc, ShouldNotEqual, mci) // two impls with the same memcacheD
ata |
32 | 33 |
33 Convey("implements MCSingleReadWriter", func() { | 34 Convey("implements MCSingleReadWriter", func() { |
34 Convey("Add", func() { | 35 Convey("Add", func() { |
35 itm := &memcache.Item{ | 36 itm := &memcache.Item{ |
36 Key: "sup", | 37 Key: "sup", |
37 Value: []byte("cool"), | 38 Value: []byte("cool"), |
38 Expiration: time.Second, | 39 Expiration: time.Second, |
39 } | 40 } |
40 err := mc.Add(itm) | 41 err := mc.Add(itm) |
41 So(err, ShouldBeNil) | 42 So(err, ShouldBeNil) |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 testItem := &memcache.Item{ | 211 testItem := &memcache.Item{ |
211 Key: "sup", | 212 Key: "sup", |
212 Value: []byte("cool"), | 213 Value: []byte("cool"), |
213 } | 214 } |
214 unsafe.MCSetCasID(testItem, 1) | 215 unsafe.MCSetCasID(testItem, 1) |
215 So(el, ShouldResemble, testItem) | 216 So(el, ShouldResemble, testItem) |
216 }) | 217 }) |
217 | 218 |
218 }) | 219 }) |
219 } | 220 } |
OLD | NEW |