Skip to content

Commit

Permalink
chore: fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartp44 committed Oct 8, 2024
1 parent 0785cfa commit ddae611
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lambdas/functions/ami-housekeeper/src/lambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Housekeeper ami', () => {
resolve();
});
});
expect(await handler(undefined, context)).resolves;
await expect(handler(undefined, context)).resolves.toBeUndefined();
});

it('should not thow only log in error in case of an exception.', async () => {
Expand Down
2 changes: 1 addition & 1 deletion lambdas/functions/control-plane/src/aws/runners.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ describe('create runner with errors', () => {
it('test now error is thrown if an instance is created', async () => {
createFleetMockWithErrors(['NonMappedError'], ['i-123']);

expect(await createRunner(createRunnerConfig(defaultRunnerConfig))).resolves;
await expect(createRunner(createRunnerConfig(defaultRunnerConfig))).resolves.toEqual(['i-123']);
expect(mockEC2Client).toHaveReceivedCommandWith(
CreateFleetCommand,
expectedCreateFleetRequest(defaultExpectedFleetRequestValues),
Expand Down
2 changes: 1 addition & 1 deletion lambdas/functions/control-plane/src/github/octokit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Test getOctokit', () => {
mockOctokit.apps.getOrgInstallation.mockRejectedValue(new Error('Error'));
}

expect(await getOctokit('', input.orgLevelRunner, payload)).resolves;
await expect(getOctokit('', input.orgLevelRunner, payload)).resolves.toBeDefined();

if (output.callOrgInstallation) {
expect(mockOctokit.apps.getOrgInstallation).toHaveBeenCalled();
Expand Down
6 changes: 3 additions & 3 deletions lambdas/functions/control-plane/src/lambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Test scale up lambda wrapper.', () => {
resolve();
});
});
expect(await scaleUpHandler(sqsEvent, context)).resolves;
await expect(scaleUpHandler(sqsEvent, context)).resolves.toBeUndefined();
});

it('Non scale should resolve.', async () => {
Expand Down Expand Up @@ -206,7 +206,7 @@ describe('Test job retry check wrapper', () => {
resolve();
});
});
expect(await jobRetryCheck(sqsEvent, context)).resolves;
await expect(jobRetryCheck(sqsEvent, context)).resolves.not.toThrow();
});

it('Handle with error should resolve and log only a warning.', async () => {
Expand All @@ -216,7 +216,7 @@ describe('Test job retry check wrapper', () => {
const error = new Error('Error handling retry check.');
mock.mockRejectedValue(error);

expect(await jobRetryCheck(sqsEvent, context)).resolves;
await expect(jobRetryCheck(sqsEvent, context)).resolves.not.toThrow('Error handling retry check.');
expect(logSpyWarn).toHaveBeenCalledWith(expect.stringContaining(error.message), expect.anything());
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ describe('Scale down runners', () => {
expect(listEC2Runners).toHaveBeenCalledWith({
environment: ENVIRONMENT,
});
expect(terminateRunner).not;
expect(mockOctokit.apps.getRepoInstallation).not;
expect(mockOctokit.apps.getRepoInstallation).not;
expect(terminateRunner).not.toHaveBeenCalled();
expect(mockOctokit.apps.getRepoInstallation).not.toHaveBeenCalled();
expect(mockOctokit.apps.getRepoInstallation).not.toHaveBeenCalled();
});

it(`Should terminate runner without idle config ${type} runners.`, async () => {
Expand Down
2 changes: 1 addition & 1 deletion lambdas/functions/gh-agent-syncer/src/syncer/syncer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function getCachedVersion(s3Client: S3Client, cacheObject: CacheObject): P
const objectTagging = await s3Client.send(command);
const versions = objectTagging.TagSet?.filter((t: Tag) => t.Key === versionKey);
return versions?.length === 1 ? versions[0].Value : undefined;
} catch (e) {
} catch {
logger.debug('No tags found');
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion lambdas/functions/termination-watcher/src/lambda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Handle sport termination interruption warning', () => {
resolve();
});
});
expect(await interruptionWarning(event, context)).resolves;
await expect(interruptionWarning(event, context)).resolves.toBeUndefined();
});

it('should not throw only log in error in case of an exception.', async () => {
Expand Down
1 change: 1 addition & 0 deletions lambdas/functions/termination-watcher/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EventBridgeEvent } from 'aws-lambda';

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface SpotInterruptionWarning<SpotTerminationDetail>
extends EventBridgeEvent<'EC2 Spot Instance Interruption Warning', SpotTerminationDetail> {}

Expand Down
17 changes: 9 additions & 8 deletions lambdas/functions/webhook/src/sqs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ describe('Test sending message to SQS.', () => {
QueueUrl: queueUrl,
MessageBody: JSON.stringify(no_fifo_message),
};

// Act
const result = await sendActionRequest(no_fifo_message);
const result = sendActionRequest(no_fifo_message);

// Assert
expect(mockSQS.sendMessage).toBeCalledWith(sqsMessage);
expect(result).resolves;
expect(mockSQS.sendMessage).toHaveBeenCalledWith(sqsMessage);
await expect(result).resolves.toBeUndefined();
});

it('use a fifo queue', async () => {
Expand All @@ -64,11 +65,11 @@ describe('Test sending message to SQS.', () => {
MessageBody: JSON.stringify(fifo_message),
};
// Act
const result = await sendActionRequest(fifo_message);
const result = sendActionRequest(fifo_message);

// Assert
expect(mockSQS.sendMessage).toBeCalledWith({ ...sqsMessage, MessageGroupId: String(message.id) });
expect(result).resolves;
expect(mockSQS.sendMessage).toHaveBeenCalledWith({ ...sqsMessage, MessageGroupId: String(message.id) });
await expect(result).resolves.toBeUndefined();
});
});

Expand All @@ -94,11 +95,11 @@ describe('Test sending message to SQS.', () => {
const config = await Config.load();

// Act
const result = await sendWebhookEventToWorkflowJobQueue(message, config);
const result = sendWebhookEventToWorkflowJobQueue(message, config);

// Assert
expect(mockSQS.sendMessage).toHaveBeenCalledWith(sqsMessage);
expect(result).resolves;
await expect(result).resolves.toBeUndefined();
});

it('Does not send webhook events to workflow job event copy queue when job queue is not in environment', async () => {
Expand Down
6 changes: 3 additions & 3 deletions lambdas/libs/aws-ssm-util/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe('Test getParameter and putParameter', () => {
},
};

mockSSMClient.on(PutParameterCommand).resolves(output);
mockSSMClient.on(PutParameterCommand).rejects(output);

// Act
expect(putParameter(parameterName, parameterValue, true)).rejects;
await expect(putParameter(parameterName, parameterValue, true)).rejects.toThrow();
});

it('Puts parameters and returns success', async () => {
Expand All @@ -75,7 +75,7 @@ describe('Test getParameter and putParameter', () => {
mockSSMClient.on(PutParameterCommand).resolves(output);

// Act
expect(putParameter(parameterName, parameterValue, true)).resolves;
await expect(putParameter(parameterName, parameterValue, true)).resolves.toBeUndefined();
});

it('Puts parameters as String', async () => {
Expand Down

0 comments on commit ddae611

Please sign in to comment.