-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for setting queue rate limit
- Loading branch information
1 parent
b5f445b
commit 218c257
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Redis } from 'ioredis'; | ||
import { | ||
flushAll, | ||
quit, | ||
createClientAndLoadLuaScripts, | ||
} from '../../utils/redis'; | ||
import { createUuid } from '../../utils/general'; | ||
import { redisConfig } from '../config'; | ||
import { setQueueRateLimit } from '../../actions/set-queue-rate-limit'; | ||
import { getQueueRateLimitConfig } from '../../actions/get-queue-rate-limit-config'; | ||
|
||
describe('setQueueRateLimit', () => { | ||
const queue = createUuid(); | ||
let client: Redis; | ||
|
||
beforeAll(() => { | ||
client = createClientAndLoadLuaScripts(redisConfig); | ||
}); | ||
|
||
beforeEach(async () => { | ||
await flushAll({ client }); | ||
}); | ||
|
||
afterAll(async () => { | ||
await quit({ client }); | ||
}); | ||
|
||
it('setQueueRateLimit sets queue rate limit', async () => { | ||
const rateLimitConfig = { points: 100, duration: 60 }; | ||
await setQueueRateLimit({ | ||
points: rateLimitConfig.points, | ||
duration: rateLimitConfig.duration, | ||
queue, | ||
client, | ||
}); | ||
const fetchedRateLimitConfig = await getQueueRateLimitConfig({ | ||
queue, | ||
client, | ||
}); | ||
expect(fetchedRateLimitConfig?.duration).toBe(rateLimitConfig.duration); | ||
expect(fetchedRateLimitConfig?.points).toBe(rateLimitConfig.points); | ||
}); | ||
}); |