Skip to content

Commit

Permalink
removed time log
Browse files Browse the repository at this point in the history
  • Loading branch information
iambenkay committed Dec 17, 2020
1 parent ef2377c commit a945c80
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions middleware/rate_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ func TestRateLimiter(t *testing.T) {
id string
code int
}{
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 429},
{"127.0.0.1", 200},
{"127.0.0.1", 429},
{"127.0.0.1", 429},
{"127.0.0.1", 429},
}

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

assert.Equal(t, tc.code, rec.Code)
time.Sleep(500 * time.Millisecond)
}
}

Expand All @@ -66,13 +65,13 @@ func TestRateLimiterWithConfig(t *testing.T) {
id string
code int
}{
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 200},
{"127.0.0.1", 429},
{"127.0.0.1", 200},
{"127.0.0.1", 429},
{"127.0.0.1", 429},
{"127.0.0.1", 429},
}

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

assert.Equal(t, tc.code, rec.Code)
time.Sleep(500 * time.Millisecond)
}
}

Expand All @@ -105,19 +103,18 @@ func TestInMemoryStore_ShouldAllow(t *testing.T) {
id string
allowed bool
}{
{"127.0.0.1", true},
{"127.0.0.1", true},
{"127.0.0.1", true},
{"127.0.0.1", true},
{"127.0.0.1", true},
{"127.0.0.1", false},
{"127.0.0.1", true},
{"127.0.0.1", false},
{"127.0.0.1", false},
{"127.0.0.1", false},
}

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

assert.Equal(t, tc.allowed, allowed)
time.Sleep(500 * time.Millisecond)
}
}

0 comments on commit a945c80

Please sign in to comment.