Debian Codegraph @

testing/redis.go

raw
1 // Copyright (c) 2014-2019 Ludovic Fauvet
2 // Licensed under the MIT license
3
4 package testing
5
6 import (
7 "github.com/etix/mirrorbits/database"
8 "github.com/gomodule/redigo/redis"
9 "github.com/rafaeljusto/redigomock"
10 )
11
12 type redisPoolMock struct {
13 Conn *redigomock.Conn
14 }
15
16 func (r *redisPoolMock) Get() redis.Conn {
17 return r.Conn
18 }
19
20 func (r *redisPoolMock) Close() error {
21 return nil
22 }
23
24 // PrepareRedisTest initialize redis tests
25 func PrepareRedisTest() (*redigomock.Conn, *database.Redis) {
26 mock := redigomock.NewConn()
27
28 pool := &redisPoolMock{
29 Conn: mock,
30 }
31
32 conn := database.NewRedisCustomPool(pool)
33
34 return mock, conn
35 }