Skip to content

Commit acc9430

Browse files
committed
Fixed rate limit test case
1 parent c74f37e commit acc9430

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

packages/contentstack-config/test/unit/commands/rate-limit.test.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,32 @@ describe('Rate Limit Commands', () => {
5555

5656
it('Set Rate Limit: should handle invalid utilization percentages', async () => {
5757
const args = ['--org', 'test-org-id', '--utilize', '150', '--limit-name', 'getLimit'];
58-
await SetRateLimitCommand.run(args);
59-
expect(errorMessage).to.equal('Utilize percentages must be numbers between 0 and 100.');
58+
try {
59+
await SetRateLimitCommand.run(args);
60+
expect.fail('Expected command to exit with error');
61+
} catch (error) {
62+
expect(error.oclif.exit).to.equal(1);
63+
}
6064
});
6165

6266
it('Set Rate Limit: should handle mismatch between utilize percentages and limit names', async () => {
6367
const args = ['--org', 'test-org-id', '--utilize', '70', '--limit-name', 'getLimit,postLimit'];
64-
await SetRateLimitCommand.run(args);
65-
expect(errorMessage).to.equal(
66-
'The number of utilization percentages must match the number of limit names provided.',
67-
);
68+
try {
69+
await SetRateLimitCommand.run(args);
70+
expect.fail('Expected command to exit with error');
71+
} catch (error) {
72+
expect(error.oclif.exit).to.equal(1);
73+
}
6874
});
6975

7076
it('Set Rate Limit: should handle invalid number of limit names', async () => {
7177
const args = ['--org', 'test-org-id', '--utilize', '70,80', '--limit-name', 'getLimit'];
72-
await SetRateLimitCommand.run(args);
73-
expect(errorMessage).to.equal(
74-
'The number of utilization percentages must match the number of limit names provided.',
75-
);
78+
try {
79+
await SetRateLimitCommand.run(args);
80+
expect.fail('Expected command to exit with error');
81+
} catch (error) {
82+
expect(error.oclif.exit).to.equal(1);
83+
}
7684
});
7785

7886
it('Set Rate Limit: should prompt for the organization UID', async () => {

0 commit comments

Comments
 (0)