Esempio n. 1
0
func redisConnection() redis.Conn {
	var connection redis.Conn
	var err error

	if len(os.Getenv("REDIS_URL")) > 0 {
		connection, err = redisurl.Connect()
	} else {
		connection, err = redis.Dial("tcp", ":6379")
	}

	check(err)

	return connection
}
Esempio n. 2
0
func TestConnect(t *testing.T) {
	c, err := redisurl.Connect()

	if err != nil {
		t.Errorf("Error returned")
	}

	pong, err := redis.String(c.Do("PING"))

	if err != nil {
		t.Errorf("Call to PING returned an error: %v", err)
	}

	if pong != "PONG" {
		t.Errorf("Wanted PONG, got %v\n", pong)
	}
}