Skip to content

Commit c392917

Browse files
Copilotaviadhahami
andcommitted
Address code review: add empty string leaseId test, improve test comments
Co-authored-by: aviadhahami <7353632+aviadhahami@users.noreply.github.com> Agent-Logs-Url: https://github.com/nodevault/node-vault/sessions/d86303c3-13a8-4f83-9355-64b288991fa5
1 parent b4b44b6 commit c392917

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/unit.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ describe('node-vault', () => {
12581258
expect(() => vault.startLeaseRenewal(null, 100)).to.throw('leaseId is required');
12591259
});
12601260

1261+
it('should throw if leaseId is empty string', () => {
1262+
expect(() => vault.startLeaseRenewal('', 100)).to.throw('leaseId is required');
1263+
});
1264+
12611265
it('should throw if leaseDuration is not positive', () => {
12621266
expect(() => vault.startLeaseRenewal('lease-1', 0)).to.throw('leaseDuration must be positive');
12631267
});
@@ -1308,10 +1312,12 @@ describe('node-vault', () => {
13081312
response.body = { lease_duration: 100, renewable: true };
13091313
vault.startLeaseRenewal('lease-1', 100);
13101314
vault.startLeaseRenewal('lease-2', 200);
1311-
await clock.tickAsync(80 * 1000); // Only lease-1 should renew
1315+
// At t=80s: lease-1 renews (80% of 100s)
1316+
await clock.tickAsync(80 * 1000);
13121317
request.callCount.should.equal(1);
1313-
await clock.tickAsync(80 * 1000); // lease-2 should renew at 160s
1314-
request.callCount.should.equal(3); // lease-1 renewed again + lease-2 first renewal
1318+
// At t=160s: lease-1 renews again (80% of 100s) + lease-2 renews (80% of 200s)
1319+
await clock.tickAsync(80 * 1000);
1320+
request.callCount.should.equal(3);
13151321
});
13161322
});
13171323

0 commit comments

Comments
 (0)