-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag_test.go
53 lines (36 loc) · 1.05 KB
/
flag_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
package kredis
import "time"
func (s *KredisTestSuite) TestFlag() {
flag, err := NewFlag("flag")
s.NoError(err)
s.False(flag.IsMarked())
s.NoError(flag.Mark())
s.True(flag.IsMarked())
s.NoError(flag.Remove())
s.False(flag.IsMarked())
}
func (s *KredisTestSuite) TestMarkedFlag() {
flag, err := NewMarkedFlag("flag")
s.NoError(err)
s.True(flag.IsMarked())
}
// TODO refactor test to check redis cmds with some sort of test env
// ProcessHook
func (s *KredisTestSuite) TestFlagWithMarkOptions() {
s.T().Skip()
flag, _ := NewFlag("flag_ex")
s.NoError(flag.Mark(WithFlagExpiry("2ms")))
s.True(flag.IsMarked())
time.Sleep(1 * time.Millisecond)
s.NoError(flag.Mark(WithFlagExpiry("2ms")))
s.True(flag.IsMarked())
time.Sleep(2 * time.Millisecond)
s.False(flag.IsMarked())
s.NoError(flag.Mark(WithFlagExpiry("2ms")))
s.True(flag.IsMarked())
time.Sleep(1 * time.Millisecond)
s.NoError(flag.Mark(WithFlagExpiry("5ms")))
s.True(flag.IsMarked())
time.Sleep(2 * time.Millisecond)
s.True(flag.IsMarked()) // still marked because of forced SET cmd
}