func (t *RedisTest) TestRedisConfigWithArgs() {
	config := &services.RedisConfig{Addr: "somehost:6379"}
	services.SetRedisConfig(config)
	t.AssertEqual("somehost:6379", config.Addr)
	t.AssertEqual("", config.Password)
	t.AssertEqual(0, config.DB)
}
func (t *RedisTest) TestDefaultRedisConfig() {
	config := &services.RedisConfig{}
	services.SetRedisConfig(config)
	t.AssertEqual("localhost:6379", config.Addr)
	t.AssertEqual("", config.Password)
	t.AssertEqual(0, config.DB)
}
func (t *RedisTest) TestRedisNewClient() {
	config := &services.RedisConfig{}
	services.SetRedisConfig(config)
	client := services.NewRedisClient(config)
	r, err := client.Ping().Result()
	t.AssertEqual("PONG", r)
	t.AssertEqual(nil, err)
}
Exemple #4
0
package models

import (
	"github.com/memikequinn/lfs-server-go/app/services"
	"github.com/revel/revel"
	"gopkg.in/redis.v3"
)

func init() {
	revel.OnAppStart(InitRedis)
}

var RedisClient *redis.Client
var InitRedis func() = func() {
	config := &services.RedisConfig{}
	services.SetRedisConfig(config)
	RedisClient = services.NewRedisClient(config)
}