Skip to content

Commit

Permalink
update for v5
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Jul 6, 2024
1 parent c3aaa99 commit 8b9dfab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
30 changes: 10 additions & 20 deletions test/global-rate-limit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,8 @@ test('With redis store', async t => {
t.equal(res.headers['x-ratelimit-remaining'], '1')
t.equal(res.headers['x-ratelimit-reset'], '1')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('With redis store (ban)', async t => {
Expand Down Expand Up @@ -531,10 +529,8 @@ test('With redis store (ban)', async t => {
t.equal(res.headers['x-ratelimit-remaining'], '0')
t.equal(res.headers['x-ratelimit-reset'], '1')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('Skip on redis error', async t => {
Expand Down Expand Up @@ -1313,10 +1309,8 @@ test('When continue exceeding is on (Redis)', async t => {
t.equal(second.headers['x-ratelimit-remaining'], '0')
t.equal(second.headers['x-ratelimit-reset'], '5')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('Redis with continueExceeding should not always return the timeWindow as ttl', async t => {
Expand Down Expand Up @@ -1372,10 +1366,8 @@ test('Redis with continueExceeding should not always return the timeWindow as tt
t.equal(res.headers['x-ratelimit-remaining'], '0')
t.equal(res.headers['x-ratelimit-reset'], '3')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('When use a custom nameSpace', async t => {
Expand Down Expand Up @@ -1437,10 +1429,8 @@ test('When use a custom nameSpace', async t => {
t.equal(res.headers['x-ratelimit-remaining'], '1')
t.equal(res.headers['x-ratelimit-reset'], '1')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('on preHandler hook', async t => {
Expand Down
18 changes: 6 additions & 12 deletions test/route-rate-limit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,8 @@ test('With redis store', async t => {
t.equal(res.headers['x-ratelimit-remaining'], '1')
t.equal(res.headers['x-ratelimit-reset'], '1')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('Throw on redis error', async t => {
Expand Down Expand Up @@ -1381,10 +1379,8 @@ test('When continue exceeding is on (Redis)', async t => {
t.equal(second.headers['x-ratelimit-remaining'], '0')
t.equal(second.headers['x-ratelimit-reset'], '5')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('When continue exceeding is off under route (Redis)', async t => {
Expand Down Expand Up @@ -1435,10 +1431,8 @@ test('When continue exceeding is off under route (Redis)', async t => {
t.equal(third.headers['x-ratelimit-remaining'], '0')
t.equal(third.headers['x-ratelimit-reset'], '3')

t.teardown(async () => {
await redis.flushall()
await redis.quit()
})
await redis.flushall()
await redis.quit()
})

test('should consider routes allow list', async t => {
Expand Down

0 comments on commit 8b9dfab

Please sign in to comment.