@@ -26,6 +26,12 @@ func Test_VerifyCode(t *testing.T) {
26
26
t .Fatal (e )
27
27
return
28
28
}
29
+
30
+ //0 empty
31
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != ErrVerifyCodeMissing {
32
+ t .Fatal ("should be verify code missing" )
33
+ return
34
+ }
29
35
//1
30
36
code , dup , e := client .MakeVerifyCode (context .Background (), "testuserid" , "testaction" , "" , 300 )
31
37
if e != nil {
@@ -36,6 +42,10 @@ func Test_VerifyCode(t *testing.T) {
36
42
t .Fatal ("should not be dup" )
37
43
return
38
44
}
45
+ if e := client .
HasCheckTimes (
context .
Background (),
"testuserid" ,
"testaction" ,
"[email protected] " );
e != ErrVerifyCodeReceiverMissing {
46
+ t .Fatal ("should be receiver missing" )
47
+ return
48
+ }
39
49
//1 dup check
40
50
newcode ,
dup ,
e := client .
MakeVerifyCode (
context .
Background (),
"testuserid" ,
"testaction" ,
"[email protected] " ,
300 )
41
51
if e != nil {
@@ -50,6 +60,10 @@ func Test_VerifyCode(t *testing.T) {
50
60
t .Fatal ("should get same code" )
51
61
return
52
62
}
63
+ if e := client .
HasCheckTimes (
context .
Background (),
"testuserid" ,
"testaction" ,
"[email protected] " );
e != nil {
64
+ t .Fatal (e )
65
+ return
66
+ }
53
67
newcode ,
dup ,
e = client .
MakeVerifyCode (
context .
Background (),
"testuserid" ,
"testaction" ,
"[email protected] " ,
300 )
54
68
if e != nil {
55
69
t .Fatal (e )
@@ -76,6 +90,10 @@ func Test_VerifyCode(t *testing.T) {
76
90
t .Fatal ("should get same code" )
77
91
return
78
92
}
93
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "123123123" ); e != nil {
94
+ t .Fatal (e )
95
+ return
96
+ }
79
97
80
98
//1 wrong receiver check
81
99
if e := client .CheckVerifyCode (context .Background (), "testuserid" , "testaction" , code , "abc" ); e != ErrVerifyCodeReceiverMissing {
@@ -86,7 +104,7 @@ func Test_VerifyCode(t *testing.T) {
86
104
}
87
105
return
88
106
}
89
- if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" ); e != nil {
107
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != nil {
90
108
t .Fatal (e )
91
109
return
92
110
}
@@ -96,7 +114,7 @@ func Test_VerifyCode(t *testing.T) {
96
114
t .Fatal (e )
97
115
return
98
116
}
99
- if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" ); e != ErrVerifyCodeMissing {
117
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != ErrVerifyCodeMissing {
100
118
t .Fatal ("should be verify code missing" )
101
119
return
102
120
}
@@ -117,7 +135,7 @@ func Test_VerifyCode(t *testing.T) {
117
135
t .Fatal (e )
118
136
return
119
137
}
120
- if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" ); e != ErrVerifyCodeMissing {
138
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != ErrVerifyCodeMissing {
121
139
t .Fatal ("should be verify code missing" )
122
140
return
123
141
}
@@ -150,7 +168,23 @@ func Test_VerifyCode(t *testing.T) {
150
168
}
151
169
return
152
170
}
153
- if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" ); e != nil {
171
+ if e := client .CheckVerifyCode (context .Background (), "testuserid" , "testaction" , "123" , "" ); e != ErrVerifyCodeWrong {
172
+ if e == nil {
173
+ t .Fatal ("should not pass" )
174
+ } else {
175
+ t .Fatal (e )
176
+ }
177
+ return
178
+ }
179
+ if e := client .CheckVerifyCode (context .Background (), "testuserid" , "testaction" , "123" , "" ); e != ErrVerifyCodeWrong {
180
+ if e == nil {
181
+ t .Fatal ("should not pass" )
182
+ } else {
183
+ t .Fatal (e )
184
+ }
185
+ return
186
+ }
187
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != nil {
154
188
t .Fatal (e )
155
189
return
156
190
}
@@ -162,7 +196,7 @@ func Test_VerifyCode(t *testing.T) {
162
196
}
163
197
return
164
198
}
165
- if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" ); e != ErrVerifyCodeCheckTimesUsedup {
199
+ if e := client .HasCheckTimes (context .Background (), "testuserid" , "testaction" , "" ); e != ErrVerifyCodeCheckTimesUsedup {
166
200
t .Fatal ("should be check times used up" )
167
201
return
168
202
}
0 commit comments