Skip to content

Commit

Permalink
Merge branch 'nv-3061-rate-limiting-nestjs-guard' into nv-3060-variab…
Browse files Browse the repository at this point in the history
…le-cost-limiter
  • Loading branch information
rifont committed Nov 28, 2023
2 parents 43e8148 + 3dc6a9d commit a5c31bd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/api/src/app/rate-limiting/guards/throttler.guard.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,12 @@ describe('API Rate Limiting', () => {
);
});

const expectedMinThrottled = expectedThrottledRequests * (1 - throttledResponseCountTollerance);
const expectedMaxThrottled = expectedThrottledRequests * (1 + throttledResponseCountTollerance);
const expectedMinThrottled = Math.floor(
expectedThrottledRequests * (1 - throttledResponseCountTollerance)
);
const expectedMaxThrottled = Math.ceil(
expectedThrottledRequests * (1 + throttledResponseCountTollerance)
);
it(`should have between ${expectedMinThrottled} and ${expectedMaxThrottled} requests throttled`, async () => {
expect(throttledResponseCount).to.be.greaterThanOrEqual(expectedMinThrottled);
expect(throttledResponseCount).to.be.lessThanOrEqual(expectedMaxThrottled);
Expand Down

0 comments on commit a5c31bd

Please sign in to comment.