Skip to content

Commit

Permalink
chore: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nmussy committed Apr 11, 2024
1 parent cc3e573 commit dd70f2b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,35 @@ test('throw error if virtualization param is set for Amazon Linux 2023', () => {
}).toThrow(/Virtualization parameter does not exist in SSM parameter name for Amazon Linux 2023./);
});

describe('windows', () => {
test('latestWindows', () => {
// WHEN
ec2.MachineImage.latestWindows(
ec2.WindowsVersion.WINDOWS_SERVER_2022_ENGLISH_CORE_BASE,
).getImage(stack);

// THEN
Template.fromStack(stack).hasParameter('*', {
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>',
Default: '/aws/service/ami-windows-latest/Windows_Server-2022-English-Core-Base',
});
});
test('latestWindows in agnostic stack', () => {
// WHEN
app = new App();
stack = new Stack(app, 'Stack');
ec2.MachineImage.latestWindows(
ec2.WindowsVersion.WINDOWS_SERVER_2022_ENGLISH_CORE_BASE,
).getImage(stack);

// THEN
Template.fromStack(stack).hasParameter('*', {
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>',
Default: '/aws/service/ami-windows-latest/Windows_Server-2022-English-Core-Base',
});
});
});

function isWindowsUserData(ud: ec2.UserData) {
return ud.render().indexOf('powershell') > -1;
}
Expand Down

0 comments on commit dd70f2b

Please sign in to comment.