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

Unified Diff: appengine/datastorecache/cache_test.go

Issue 2645763002: datastorecache: Add Locker field, public settings. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/datastorecache/cache.go ('k') | appengine/datastorecache/handler.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/datastorecache/cache_test.go
diff --git a/appengine/datastorecache/cache_test.go b/appengine/datastorecache/cache_test.go
index 65777e24c7a4be40c8d60c5a338c10e2d802f9d1..52ceeea04cfa9713bec09425b2135a382109ad6b 100644
--- a/appengine/datastorecache/cache_test.go
+++ b/appengine/datastorecache/cache_test.go
@@ -34,6 +34,12 @@ func TestCache(t *testing.T) {
cache := makeTestCache("test")
cache.refreshFn = func(context.Context, []byte, Value) (Value, error) { return currentValue, nil }
+ // otherLocker is a memLocker intance (used by makeTestCache) that
+ // identifies itself as a different client than the one running the test.
+ //
+ // This is used to create lock conflicts.
+ otherLocker := memLocker{"other client ID"}
+
Convey(`Will panic if it has neither a name or namespace configured.`, func() {
cache.Name = ""
cache.Namespace = ""
@@ -203,7 +209,7 @@ func TestCache(t *testing.T) {
// Hold the entity's refresh lock. Our cache will not be able to acquire
// it.
var v Value
- err := e.tryWithLock(cache.withNamespace(te), "test client", func(c context.Context) (err error) {
+ err := otherLocker.TryWithLock(cache.withNamespace(te), e.lockKey(), func(c context.Context) (err error) {
v, err = cache.Get(info.MustNamespace(te, "dog"), []byte("foo"))
return
})
@@ -219,7 +225,7 @@ func TestCache(t *testing.T) {
// Hold the entity's refresh lock. Our cache will not be able to acquire
// it.
- err := e.tryWithLock(cache.withNamespace(te), "test client", func(c context.Context) (err error) {
+ err := otherLocker.TryWithLock(cache.withNamespace(te), e.lockKey(), func(c context.Context) (err error) {
_, err = cache.Get(te, []byte("foo"))
return
})
@@ -240,7 +246,7 @@ func TestCache(t *testing.T) {
// Hold the entity's refresh lock. Our cache will not be able to acquire
// it.
var v Value
- err := e.tryWithLock(cache.withNamespace(te), "test client", func(c context.Context) (err error) {
+ err := otherLocker.TryWithLock(cache.withNamespace(te), e.lockKey(), func(c context.Context) (err error) {
v, err = cache.Get(te, []byte("foo"))
return
})
@@ -256,7 +262,7 @@ func TestCache(t *testing.T) {
// Hold the entity's refresh lock. Our cache will not be able to acquire
// it.
var v Value
- err := e.tryWithLock(cache.withNamespace(te), "test client", func(c context.Context) (err error) {
+ err := otherLocker.TryWithLock(cache.withNamespace(te), e.lockKey(), func(c context.Context) (err error) {
v, err = cache.Get(te, []byte("foo"))
return
})
@@ -379,7 +385,7 @@ func TestCache(t *testing.T) {
Convey(`Will ignore accessed timestamp if the entry's lock is held.`, func() {
var v Value
- err := e.tryWithLock(cache.withNamespace(te), "test client", func(c context.Context) (err error) {
+ err := otherLocker.TryWithLock(cache.withNamespace(te), e.lockKey(), func(c context.Context) (err error) {
v, err = cache.Get(te, []byte("foo"))
return
})
« no previous file with comments | « appengine/datastorecache/cache.go ('k') | appengine/datastorecache/handler.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698