From dd70f2bb01f69e87ef3aa6084cdaf185ce735d15 Mon Sep 17 00:00:00 2001 From: Jimmy Gaussen Date: Thu, 11 Apr 2024 10:25:27 +0200 Subject: [PATCH] chore: add unit test --- .../aws-ec2/test/machine-image.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts index ac2eef24611c9..e598164a789b2 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/machine-image.test.ts @@ -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', + 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', + Default: '/aws/service/ami-windows-latest/Windows_Server-2022-English-Core-Base', + }); + }); +}); + function isWindowsUserData(ud: ec2.UserData) { return ud.render().indexOf('powershell') > -1; }