1 // Copyright (c) 2012-2016 The Revel Framework Authors, All rights reserved.
2 // Revel Framework source code and usage is governed by a MIT style
3 // license that can be found in the LICENSE file.
13 // These tests require memcached running on localhost:11211 (the default)
14 const testServer = "localhost:11211"
16 var newMemcachedCache = func(t *testing.T, defaultExpiration time.Duration) Cache {
17 c, err := net.Dial("tcp", testServer)
19 if _, err = c.Write([]byte("flush_all\r\n")); err != nil {
20 t.Errorf("Write failed: %s", err)
23 return NewMemcachedCache([]string{testServer}, defaultExpiration)
25 t.Errorf("couldn't connect to memcached on %s", testServer)
30 func TestMemcachedCache_TypicalGetSet(t *testing.T) {
31 typicalGetSet(t, newMemcachedCache)
34 func TestMemcachedCache_IncrDecr(t *testing.T) {
35 incrDecr(t, newMemcachedCache)
38 func TestMemcachedCache_Expiration(t *testing.T) {
39 expiration(t, newMemcachedCache)
42 func TestMemcachedCache_EmptyCache(t *testing.T) {
43 emptyCache(t, newMemcachedCache)
46 func TestMemcachedCache_Replace(t *testing.T) {
47 testReplace(t, newMemcachedCache)
50 func TestMemcachedCache_Add(t *testing.T) {
51 testAdd(t, newMemcachedCache)
54 func TestMemcachedCache_GetMulti(t *testing.T) {
55 testGetMulti(t, newMemcachedCache)