Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iliapolo committed Nov 27, 2024
1 parent 410e99a commit 0c7146b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 5 additions & 3 deletions packages/aws-cdk/test/api/hotswap/hotswap-test-setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as cxapi from '@aws-cdk/cx-api';
import { ListStackResourcesCommand, StackResourceSummary, StackStatus } from '@aws-sdk/client-cloudformation';
import { GetFunctionConfigurationCommand } from '@aws-sdk/client-lambda';
import { GetFunctionCommand } from '@aws-sdk/client-lambda';
import { ICloudFormationClient, SuccessfulDeployStackResult } from '../../../lib/api';
import { HotswapMode, HotswapPropertyOverrides } from '../../../lib/api/hotswap/common';
import * as deployments from '../../../lib/api/hotswap-deployments';
Expand Down Expand Up @@ -109,8 +109,10 @@ export class HotswapMockSdkProvider extends MockSdkProvider {
constructor(rootStackName?: string) {
super();

mockLambdaClient.on(GetFunctionConfigurationCommand).resolves({
LastUpdateStatus: 'Successful',
mockLambdaClient.on(GetFunctionCommand).resolves({
Configuration: {
LastUpdateStatus: 'Successful',
},
});

mockCloudFormationClient.on(ListStackResourcesCommand).callsFake((input) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UpdateFunctionCodeCommand, waitUntilFunctionUpdated } from '@aws-sdk/client-lambda';
import { UpdateFunctionCodeCommand, waitUntilFunctionUpdatedV2 } from '@aws-sdk/client-lambda';
import * as setup from './hotswap-test-setup';
import { HotswapMode } from '../../../lib/api/hotswap/common';
import { mockLambdaClient } from '../../util/mock-sdk';
Expand All @@ -9,7 +9,7 @@ jest.mock('@aws-sdk/client-lambda', () => {

return {
...original,
waitUntilFunctionUpdated: jest.fn(),
waitUntilFunctionUpdatedV2: jest.fn(),
};
});

Expand Down Expand Up @@ -116,7 +116,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
await hotswapMockSdkProvider.tryHotswapDeployment(hotswapMode, cdkStackArtifact);

// THEN
expect(waitUntilFunctionUpdated).toHaveBeenCalledWith(
expect(waitUntilFunctionUpdatedV2).toHaveBeenCalledWith(
expect.objectContaining({
minDelay: 5,
maxDelay: 5,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
UpdateFunctionCodeCommand,
UpdateFunctionConfigurationCommand,
waitUntilFunctionUpdated,
waitUntilFunctionUpdatedV2,
} from '@aws-sdk/client-lambda';
import * as setup from './hotswap-test-setup';
import { HotswapMode } from '../../../lib/api/hotswap/common';
Expand All @@ -13,7 +13,7 @@ jest.mock('@aws-sdk/client-lambda', () => {

return {
...original,
waitUntilFunctionUpdated: jest.fn(),
waitUntilFunctionUpdatedV2: jest.fn(),
};
});

Expand Down Expand Up @@ -617,7 +617,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot

// THEN
expect(mockLambdaClient).toHaveReceivedCommand(UpdateFunctionCodeCommand);
expect(waitUntilFunctionUpdated).toHaveBeenCalledWith(
expect(waitUntilFunctionUpdatedV2).toHaveBeenCalledWith(
expect.objectContaining({
minDelay: 1,
maxDelay: 1,
Expand Down Expand Up @@ -675,7 +675,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
await hotswapMockSdkProvider.tryHotswapDeployment(hotswapMode, cdkStackArtifact);

// THEN
expect(waitUntilFunctionUpdated).toHaveBeenCalledWith(
expect(waitUntilFunctionUpdatedV2).toHaveBeenCalledWith(
expect.objectContaining({
minDelay: 1,
maxDelay: 1,
Expand Down Expand Up @@ -733,7 +733,7 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot
await hotswapMockSdkProvider.tryHotswapDeployment(hotswapMode, cdkStackArtifact);

// THEN
expect(waitUntilFunctionUpdated).toHaveBeenCalledWith(
expect(waitUntilFunctionUpdatedV2).toHaveBeenCalledWith(
expect.objectContaining({
minDelay: 5,
maxDelay: 5,
Expand Down

0 comments on commit 0c7146b

Please sign in to comment.