chore: replace redis.NewRedis with redis.New (#1103)
This commit is contained in:
@@ -24,7 +24,7 @@ func TestTokenLimit_Rescue(t *testing.T) {
|
|||||||
rate = 5
|
rate = 5
|
||||||
burst = 10
|
burst = 10
|
||||||
)
|
)
|
||||||
l := NewTokenLimiter(rate, burst, redis.NewRedis(s.Addr(), redis.NodeType), "tokenlimit")
|
l := NewTokenLimiter(rate, burst, redis.New(s.Addr()), "tokenlimit")
|
||||||
s.Close()
|
s.Close()
|
||||||
|
|
||||||
var allowed int
|
var allowed int
|
||||||
|
|||||||
2
core/stores/cache/cachenode_test.go
vendored
2
core/stores/cache/cachenode_test.go
vendored
@@ -73,7 +73,7 @@ func TestCacheNode_InvalidCache(t *testing.T) {
|
|||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
cn := cacheNode{
|
cn := cacheNode{
|
||||||
rds: redis.NewRedis(s.Addr(), redis.NodeType),
|
rds: redis.New(s.Addr()),
|
||||||
r: rand.New(rand.NewSource(time.Now().UnixNano())),
|
r: rand.New(rand.NewSource(time.Now().UnixNano())),
|
||||||
lock: new(sync.Mutex),
|
lock: new(sync.Mutex),
|
||||||
unstableExpiry: mathx.NewUnstable(expiryDeviation),
|
unstableExpiry: mathx.NewUnstable(expiryDeviation),
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ func TestStatCacheFails(t *testing.T) {
|
|||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(ioutil.Discard)
|
||||||
defer log.SetOutput(os.Stdout)
|
defer log.SetOutput(os.Stdout)
|
||||||
|
|
||||||
r := redis.NewRedis("localhost:59999", redis.NodeType)
|
r := redis.New("localhost:59999")
|
||||||
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
cach := cache.NewNode(r, sharedCalls, stats, mgo.ErrNotFound)
|
||||||
c := newCollection(dummyConn{}, cach)
|
c := newCollection(dummyConn{}, cach)
|
||||||
|
|
||||||
|
|||||||
@@ -963,7 +963,7 @@ func TestRedis_Pipelined(t *testing.T) {
|
|||||||
func TestRedisString(t *testing.T) {
|
func TestRedisString(t *testing.T) {
|
||||||
runOnRedis(t, func(client *Redis) {
|
runOnRedis(t, func(client *Redis) {
|
||||||
client.Ping()
|
client.Ping()
|
||||||
_, err := getRedis(NewRedis(client.Addr, ClusterType))
|
_, err := getRedis(New(client.Addr, Cluster()))
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, client.Addr, client.String())
|
assert.Equal(t, client.Addr, client.String())
|
||||||
assert.NotNil(t, New(client.Addr, badType()).Ping())
|
assert.NotNil(t, New(client.Addr, badType()).Ping())
|
||||||
@@ -1075,7 +1075,7 @@ func TestRedisGeo(t *testing.T) {
|
|||||||
|
|
||||||
func TestRedis_WithPass(t *testing.T) {
|
func TestRedis_WithPass(t *testing.T) {
|
||||||
runOnRedis(t, func(client *Redis) {
|
runOnRedis(t, func(client *Redis) {
|
||||||
err := NewRedis(client.Addr, NodeType, "any").Ping()
|
err := New(client.Addr, WithPass("any")).Ping()
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1095,7 +1095,7 @@ func runOnRedis(t *testing.T, fn func(client *Redis)) {
|
|||||||
client.Close()
|
client.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
fn(NewRedis(s.Addr(), NodeType))
|
fn(New(s.Addr()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func runOnRedisTLS(t *testing.T, fn func(client *Redis)) {
|
func runOnRedisTLS(t *testing.T, fn func(client *Redis)) {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import (
|
|||||||
func TestBlockingNode(t *testing.T) {
|
func TestBlockingNode(t *testing.T) {
|
||||||
r, err := miniredis.Run()
|
r, err := miniredis.Run()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
node, err := CreateBlockingNode(NewRedis(r.Addr(), NodeType))
|
node, err := CreateBlockingNode(New(r.Addr()))
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
node.Close()
|
node.Close()
|
||||||
node, err = CreateBlockingNode(NewRedis(r.Addr(), ClusterType))
|
node, err = CreateBlockingNode(New(r.Addr(), Cluster()))
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
node.Close()
|
node.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func CreateRedis() (r *redis.Redis, clean func(), err error) {
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return redis.NewRedis(mr.Addr(), redis.NodeType), func() {
|
return redis.New(mr.Addr()), func() {
|
||||||
ch := make(chan lang.PlaceholderType)
|
ch := make(chan lang.PlaceholderType)
|
||||||
go func() {
|
go func() {
|
||||||
mr.Close()
|
mr.Close()
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ func TestStatCacheFails(t *testing.T) {
|
|||||||
log.SetOutput(ioutil.Discard)
|
log.SetOutput(ioutil.Discard)
|
||||||
defer log.SetOutput(os.Stdout)
|
defer log.SetOutput(os.Stdout)
|
||||||
|
|
||||||
r := redis.NewRedis("localhost:59999", redis.NodeType)
|
r := redis.New("localhost:59999")
|
||||||
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
|
c := NewNodeConn(dummySqlConn{}, r, cache.WithExpiry(time.Second*10))
|
||||||
|
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
@@ -485,7 +485,7 @@ func TestCachedConnExecDropCache(t *testing.T) {
|
|||||||
value = "any"
|
value = "any"
|
||||||
)
|
)
|
||||||
var conn trackedConn
|
var conn trackedConn
|
||||||
c := NewNodeConn(&conn, redis.NewRedis(r.Addr(), redis.NodeType), cache.WithExpiry(time.Second*30))
|
c := NewNodeConn(&conn, redis.New(r.Addr()), cache.WithExpiry(time.Second*30))
|
||||||
assert.Nil(t, c.SetCache(key, value))
|
assert.Nil(t, c.SetCache(key, value))
|
||||||
_, err = c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
_, err = c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
||||||
return conn.Exec("delete from user_table where id='kevin'")
|
return conn.Exec("delete from user_table where id='kevin'")
|
||||||
@@ -503,7 +503,7 @@ func TestCachedConnExecDropCache(t *testing.T) {
|
|||||||
func TestCachedConnExecDropCacheFailed(t *testing.T) {
|
func TestCachedConnExecDropCacheFailed(t *testing.T) {
|
||||||
const key = "user"
|
const key = "user"
|
||||||
var conn trackedConn
|
var conn trackedConn
|
||||||
r := redis.NewRedis("anyredis:8888", redis.NodeType)
|
r := redis.New("anyredis:8888")
|
||||||
c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*10))
|
c := NewNodeConn(&conn, r, cache.WithExpiry(time.Second*10))
|
||||||
_, err := c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
_, err := c.Exec(func(conn sqlx.SqlConn) (result sql.Result, e error) {
|
||||||
return conn.Exec("delete from user_table where id='kevin'")
|
return conn.Exec("delete from user_table where id='kevin'")
|
||||||
|
|||||||
Reference in New Issue
Block a user