...

Source file src/github.com/gin-contrib/sessions/redis/redis_test.go

Documentation: github.com/gin-contrib/sessions/redis

     1  package redis
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gin-contrib/sessions"
     7  	"github.com/gin-contrib/sessions/tester"
     8  )
     9  
    10  const redisTestServer = "localhost:6379"
    11  
    12  var newRedisStore = func(_ *testing.T) sessions.Store {
    13  	store, err := NewStore(10, "tcp", redisTestServer, "", []byte("secret"))
    14  	if err != nil {
    15  		panic(err)
    16  	}
    17  	return store
    18  }
    19  
    20  func TestRedis_SessionGetSet(t *testing.T) {
    21  	tester.GetSet(t, newRedisStore)
    22  }
    23  
    24  func TestRedis_SessionDeleteKey(t *testing.T) {
    25  	tester.DeleteKey(t, newRedisStore)
    26  }
    27  
    28  func TestRedis_SessionFlashes(t *testing.T) {
    29  	tester.Flashes(t, newRedisStore)
    30  }
    31  
    32  func TestRedis_SessionClear(t *testing.T) {
    33  	tester.Clear(t, newRedisStore)
    34  }
    35  
    36  func TestRedis_SessionOptions(t *testing.T) {
    37  	tester.Options(t, newRedisStore)
    38  }
    39  
    40  func TestRedis_SessionMany(t *testing.T) {
    41  	tester.Many(t, newRedisStore)
    42  }
    43  
    44  func TestGetRedisStore(t *testing.T) {
    45  	t.Run("unmatched type", func(t *testing.T) {
    46  		type store struct{ Store }
    47  		err, rediStore := GetRedisStore(store{})
    48  		if err == nil || rediStore != nil {
    49  			t.Fail()
    50  		}
    51  	})
    52  }
    53  

View as plain text