@@ -17,6 +17,14 @@ func TestRedisLockerImplLockerValue(t *testing.T) {
17
17
}
18
18
19
19
func TestRedisLockPanic (t * testing.T ) {
20
+ t .Run ("RedisLockPanic-Init-Panic" , func (t * testing.T ) {
21
+ if redis .GetInstance () == nil && redis .GetClusterInstance () == nil {
22
+ assert .Panics (t , func () {
23
+ t .Log (RedisLocker ())
24
+ })
25
+ }
26
+ })
27
+
20
28
t .Run ("RedisLockPanic-Lock" , func (t * testing.T ) {
21
29
if redis .GetInstance () == nil && redis .GetClusterInstance () == nil {
22
30
assert .Panics (t , func () {
@@ -31,7 +39,16 @@ func TestRedisLockPanic(t *testing.T) {
31
39
t .Run ("RedisLockPanic-TryLock" , func (t * testing.T ) {
32
40
if redis .GetInstance () == nil && redis .GetClusterInstance () == nil {
33
41
assert .Panics (t , func () {
34
- key := "go-sail-redisLocker-Lock"
42
+ key := "go-sail-redisLocker-TryLock"
43
+ RedisLocker ().TryLock (key )
44
+ })
45
+ }
46
+ })
47
+
48
+ t .Run ("RedisLockPanic-TryLockWithContext" , func (t * testing.T ) {
49
+ if redis .GetInstance () == nil && redis .GetClusterInstance () == nil {
50
+ assert .Panics (t , func () {
51
+ key := "go-sail-redisLocker-TryLockWithContext"
35
52
RedisLocker ().TryLock (key )
36
53
})
37
54
}
@@ -40,7 +57,7 @@ func TestRedisLockPanic(t *testing.T) {
40
57
t .Run ("RedisLockPanic-UnlockWithContext" , func (t * testing.T ) {
41
58
if redis .GetInstance () == nil && redis .GetClusterInstance () == nil {
42
59
assert .Panics (t , func () {
43
- key := "go-sail-redisLocker-Lock "
60
+ key := "go-sail-redisLocker-UnlockWithContext "
44
61
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
45
62
defer cancel ()
46
63
RedisLocker ().UnlockWithContext (ctx , key )
@@ -88,7 +105,7 @@ func TestRedisLock(t *testing.T) {
88
105
})
89
106
90
107
t .Run ("Unlock-WithContext" , func (t * testing.T ) {
91
- key := "go-sail-redisLocker-Unlock "
108
+ key := "go-sail-redisLocker-UnlockWithContext "
92
109
t .Log (RedisLocker ().TryLock (key ))
93
110
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
94
111
defer cancel ()
@@ -148,7 +165,7 @@ func TestRedisClusterLock(t *testing.T) {
148
165
})
149
166
150
167
t .Run ("Unlock-WithContext" , func (t * testing.T ) {
151
- key := "go-sail-redisLocker-Unlock "
168
+ key := "go-sail-redisLocker-UnlockWithContext "
152
169
t .Log (RedisLocker ().TryLock (key ))
153
170
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
154
171
defer cancel ()
0 commit comments