-
Notifications
You must be signed in to change notification settings - Fork 9
/
redis_test.go
37 lines (32 loc) · 999 Bytes
/
redis_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package goenv
import (
"testing"
)
func TestGetRedis(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "redis", "nil")
host, port, db := goenv.GetRedis()
if host != "ecr" || port != "340" || db != 16 {
t.Error("redis != ecr, 340, 16")
}
}
func TestGetRedisNotFound(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "nonexistent", "nil")
host, port, db := goenv.GetRedis()
if host != "localhost" || port != "6379" || db != -1 {
t.Error("redis != localhost, 6379, -1")
}
}
func TestGetNamedRedis(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "redis", "nil")
host, port, db := goenv.GetNamedRedis("custom")
if host != "ruo" || port != "114" || db != 81 {
t.Error("custom != ruo, 114, 81")
}
}
func TestGetNamedRedisNotFound(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "redis", "nil")
host, port, db := goenv.GetNamedRedis("nonexistent")
if host != "localhost" || port != "6379" || db != -1 {
t.Error("nonexistent != localhost, 6379, -1")
}
}