-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathredis_test.go
38 lines (28 loc) · 843 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
38
package goralim
import(
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewRedisClient(t *testing.T){
// Test with valid config
validConfig := RedisConfig{
HOST: "localhost",
PORT: 6379,
PASS: "",
}
redisClientWithValidConfig := NewRedisClient(validConfig)
assert.NotNil(t, redisClientWithValidConfig)
_, err := redisClientWithValidConfig.Ping().Result()
assert.NoError(t, err)
// Test with invalid config
invalidConfig := RedisConfig{
HOST: "invalidhost",
PORT: 1234,
PASS: "",
}
redisClientWithWrongConfig := NewRedisClient(invalidConfig)
assert.Nil(t, redisClientWithWrongConfig)
// Test with nil config
redisClientWithNilConfig := NewRedisClient(RedisConfig{})
assert.Nil(t, redisClientWithNilConfig)
}