-
Notifications
You must be signed in to change notification settings - Fork 0
/
hash_test.go
78 lines (50 loc) · 1.12 KB
/
hash_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package RedisGo_test
import (
"strconv"
"testing"
"time"
"github.com/DejanGegic/RedisGo"
)
var R = RedisGo.ConnectToRedisClient("localhost", "6379", "", 0)
func TestWriteToRedisHash(t *testing.T) {
R.FlushDB()
err := R.WriteToRedisHash(strconv.Itoa(1), strconv.Itoa(1), "test")
if err != nil {
t.Fail()
}
}
func TestWriteToRedisHashWithTTL(t *testing.T) {
R.FlushDB()
err := R.WriteToRedisHashWithTTL(strconv.Itoa(1), strconv.Itoa(1), "test", time.Second*2)
if err != nil {
t.Fail()
}
}
func TestReadFromRedisHash(t *testing.T) {
R.FlushDB()
err := R.WriteToRedisHash(strconv.Itoa(1), strconv.Itoa(1), "test")
if err != nil {
t.Fail()
}
val, err := R.ReadFromRedisHash(strconv.Itoa(1), strconv.Itoa(1))
if err != nil {
t.Fail()
}
if val != "test" {
t.Fail()
}
}
func TestReadFromRedisHashWithTTL(t *testing.T) {
R.FlushDB()
err := R.WriteToRedisHashWithTTL(strconv.Itoa(1), strconv.Itoa(1), "test", time.Second*2)
if err != nil {
t.Fail()
}
val, _, err := R.ReadFromRedisHashWithTTL(strconv.Itoa(1), strconv.Itoa(1))
if err != nil {
t.Fail()
}
if val != "test" {
t.Fail()
}
}