File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,13 @@ func TestRateLimiter(t *testing.T) {
24
24
id string
25
25
code int
26
26
}{
27
- {"127.0.0.1" , 200 },
28
- {"127.0.0.1" , 200 },
29
27
{"127.0.0.1" , 200 },
30
28
{"127.0.0.1" , 200 },
31
29
{"127.0.0.1" , 200 },
32
30
{"127.0.0.1" , 429 },
33
- {"127.0.0.1" , 200 },
31
+ {"127.0.0.1" , 429 },
32
+ {"127.0.0.1" , 429 },
33
+ {"127.0.0.1" , 429 },
34
34
}
35
35
36
36
for _ , tc := range testCases {
@@ -47,7 +47,6 @@ func TestRateLimiter(t *testing.T) {
47
47
_ = mw (handler )(c )
48
48
49
49
assert .Equal (t , tc .code , rec .Code )
50
- time .Sleep (500 * time .Millisecond )
51
50
}
52
51
}
53
52
@@ -66,13 +65,13 @@ func TestRateLimiterWithConfig(t *testing.T) {
66
65
id string
67
66
code int
68
67
}{
69
- {"127.0.0.1" , 200 },
70
- {"127.0.0.1" , 200 },
71
68
{"127.0.0.1" , 200 },
72
69
{"127.0.0.1" , 200 },
73
70
{"127.0.0.1" , 200 },
74
71
{"127.0.0.1" , 429 },
75
- {"127.0.0.1" , 200 },
72
+ {"127.0.0.1" , 429 },
73
+ {"127.0.0.1" , 429 },
74
+ {"127.0.0.1" , 429 },
76
75
}
77
76
78
77
for _ , tc := range testCases {
@@ -92,7 +91,6 @@ func TestRateLimiterWithConfig(t *testing.T) {
92
91
_ = mw (handler )(c )
93
92
94
93
assert .Equal (t , tc .code , rec .Code )
95
- time .Sleep (500 * time .Millisecond )
96
94
}
97
95
}
98
96
@@ -105,19 +103,18 @@ func TestInMemoryStore_ShouldAllow(t *testing.T) {
105
103
id string
106
104
allowed bool
107
105
}{
108
- {"127.0.0.1" , true },
109
- {"127.0.0.1" , true },
110
106
{"127.0.0.1" , true },
111
107
{"127.0.0.1" , true },
112
108
{"127.0.0.1" , true },
113
109
{"127.0.0.1" , false },
114
- {"127.0.0.1" , true },
110
+ {"127.0.0.1" , false },
111
+ {"127.0.0.1" , false },
112
+ {"127.0.0.1" , false },
115
113
}
116
114
117
115
for _ , tc := range testCases {
118
116
allowed := inMemoryStore .ShouldAllow (tc .id )
119
117
120
118
assert .Equal (t , tc .allowed , allowed )
121
- time .Sleep (500 * time .Millisecond )
122
119
}
123
120
}
You can’t perform that action at this time.
0 commit comments