mirror of https://github.com/cloudreve/Cloudreve
Test: redis pool connection
parent
6d6255e759
commit
5b01202844
|
@ -7,13 +7,27 @@ import (
|
||||||
"github.com/rafaeljusto/redigomock"
|
"github.com/rafaeljusto/redigomock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewRedisStore(t *testing.T) {
|
func TestNewRedisStore(t *testing.T) {
|
||||||
asserts := assert.New(t)
|
asserts := assert.New(t)
|
||||||
|
|
||||||
store := NewRedisStore(10, "tcp", ":2333", "", "0")
|
store := NewRedisStore(10, "tcp", "", "", "0")
|
||||||
asserts.NotNil(store)
|
asserts.NotNil(store)
|
||||||
|
|
||||||
|
conn, err := store.pool.Dial()
|
||||||
|
asserts.Nil(conn)
|
||||||
|
asserts.Error(err)
|
||||||
|
|
||||||
|
testConn := redigomock.NewConn()
|
||||||
|
cmd := testConn.Command("PING").Expect("PONG")
|
||||||
|
err = store.pool.TestOnBorrow(testConn, time.Now())
|
||||||
|
if testConn.Stats(cmd) != 1 {
|
||||||
|
fmt.Println("Command was not used")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
asserts.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRedisStore_Set(t *testing.T) {
|
func TestRedisStore_Set(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue