Skip to content

Commit a945c80

Browse files
committed
removed time log
1 parent ef2377c commit a945c80

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

middleware/rate_limiter_test.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ func TestRateLimiter(t *testing.T) {
2424
id string
2525
code int
2626
}{
27-
{"127.0.0.1", 200},
28-
{"127.0.0.1", 200},
2927
{"127.0.0.1", 200},
3028
{"127.0.0.1", 200},
3129
{"127.0.0.1", 200},
3230
{"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},
3434
}
3535

3636
for _, tc := range testCases {
@@ -47,7 +47,6 @@ func TestRateLimiter(t *testing.T) {
4747
_ = mw(handler)(c)
4848

4949
assert.Equal(t, tc.code, rec.Code)
50-
time.Sleep(500 * time.Millisecond)
5150
}
5251
}
5352

@@ -66,13 +65,13 @@ func TestRateLimiterWithConfig(t *testing.T) {
6665
id string
6766
code int
6867
}{
69-
{"127.0.0.1", 200},
70-
{"127.0.0.1", 200},
7168
{"127.0.0.1", 200},
7269
{"127.0.0.1", 200},
7370
{"127.0.0.1", 200},
7471
{"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},
7675
}
7776

7877
for _, tc := range testCases {
@@ -92,7 +91,6 @@ func TestRateLimiterWithConfig(t *testing.T) {
9291
_ = mw(handler)(c)
9392

9493
assert.Equal(t, tc.code, rec.Code)
95-
time.Sleep(500 * time.Millisecond)
9694
}
9795
}
9896

@@ -105,19 +103,18 @@ func TestInMemoryStore_ShouldAllow(t *testing.T) {
105103
id string
106104
allowed bool
107105
}{
108-
{"127.0.0.1", true},
109-
{"127.0.0.1", true},
110106
{"127.0.0.1", true},
111107
{"127.0.0.1", true},
112108
{"127.0.0.1", true},
113109
{"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},
115113
}
116114

117115
for _, tc := range testCases {
118116
allowed := inMemoryStore.ShouldAllow(tc.id)
119117

120118
assert.Equal(t, tc.allowed, allowed)
121-
time.Sleep(500 * time.Millisecond)
122119
}
123120
}

0 commit comments

Comments
 (0)