...
1 package memcached
2
3 import (
4 "testing"
5
6 "github.com/bradfitz/gomemcache/memcache"
7 "github.com/gin-contrib/sessions"
8 "github.com/gin-contrib/sessions/tester"
9 "github.com/memcachier/mc"
10 )
11
12 const memcachedTestServer = "localhost:11211"
13
14 var newStore = func(_ *testing.T) sessions.Store {
15 store := NewStore(
16 memcache.New(memcachedTestServer), "", []byte("secret"))
17 return store
18 }
19
20 func TestMemcached_SessionGetSet(t *testing.T) {
21 tester.GetSet(t, newStore)
22 }
23
24 func TestMemcached_SessionDeleteKey(t *testing.T) {
25 tester.DeleteKey(t, newStore)
26 }
27
28 func TestMemcached_SessionFlashes(t *testing.T) {
29 tester.Flashes(t, newStore)
30 }
31
32 func TestMemcached_SessionClear(t *testing.T) {
33 tester.Clear(t, newStore)
34 }
35
36 func TestMemcached_SessionOptions(t *testing.T) {
37 tester.Options(t, newStore)
38 }
39
40 func TestMemcached_SessionMany(t *testing.T) {
41 tester.Many(t, newStore)
42 }
43
44 var newBinaryStore = func(_ *testing.T) sessions.Store {
45 store := NewMemcacheStore(
46 mc.NewMC(memcachedTestServer, "", ""), "", []byte("secret"))
47 return store
48 }
49
50 func TestBinaryMemcached_SessionGetSet(t *testing.T) {
51 tester.GetSet(t, newBinaryStore)
52 }
53
54 func TestBinaryMemcached_SessionDeleteKey(t *testing.T) {
55 tester.DeleteKey(t, newBinaryStore)
56 }
57
58 func TestBinaryMemcached_SessionFlashes(t *testing.T) {
59 tester.Flashes(t, newBinaryStore)
60 }
61
62 func TestBinaryMemcached_SessionClear(t *testing.T) {
63 tester.Clear(t, newBinaryStore)
64 }
65
66 func TestBinaryMemcached_SessionOptions(t *testing.T) {
67 tester.Options(t, newBinaryStore)
68 }
69
70 func TestBinaryMemcached_SessionMany(t *testing.T) {
71 tester.Many(t, newBinaryStore)
72 }
73
View as plain text