Skip to content

Commit

Permalink
fix validator test
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkvanmeerten committed Sep 16, 2024
1 parent 5fe45c5 commit 91b31b5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/test/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ describe('Validator', () => {
getCloudInstances: mock.fn(),
};

const shutdownManager = {
getShutdownConfirmations: mock.fn((_, instanceIds) => instanceIds.map(() => false)),
};

const groupName = 'group';

const validator = new Validator({ instanceTracker, instanceGroupManager, metricsLoop });
const validator = new Validator({ instanceTracker, instanceGroupManager, metricsLoop, shutdownManager });

afterEach(() => {
context = {
Expand Down Expand Up @@ -71,6 +75,17 @@ describe('Validator', () => {
assert.strictEqual(result, false);
});

test('should return false for a group with an instance that has sent back completed webhook', async () => {
instanceTracker.trimCurrent.mock.mockImplementationOnce(() => [
{ instanceId: '1', shutdownComplete: true },
]);
metricsLoop.getCloudInstances.mock.mockImplementationOnce(() => []);
shutdownManager.getShutdownConfirmations.mock.mockImplementationOnce(() => ['completed']);

const result = await validator.groupHasActiveInstances(context, groupName);
assert.strictEqual(result, false);
});

test('should return true for a group with one active and one shutdown instance', async () => {
instanceTracker.trimCurrent.mock.mockImplementationOnce(() => [
{ instanceId: '1' },
Expand Down

0 comments on commit 91b31b5

Please sign in to comment.