From 4bcbbdb5a3260dbc9374d1a68eb3cb1c2179c26a Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Wed, 5 Feb 2025 10:09:15 +1300 Subject: [PATCH] more windows tests (#5740) --- .../windows/components_json_helpers.tests.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vhdbuilder/packer/windows/components_json_helpers.tests.ps1 b/vhdbuilder/packer/windows/components_json_helpers.tests.ps1 index 116a5f93572..d5f1d17ed95 100644 --- a/vhdbuilder/packer/windows/components_json_helpers.tests.ps1 +++ b/vhdbuilder/packer/windows/components_json_helpers.tests.ps1 @@ -37,6 +37,14 @@ Describe 'Gets the Binaries' { $packages | ConvertTo-Json -Compress | Should -Be "{}" } + It 'given the windows block is missing, it returns an empty array' { + $componentsJson.Packages[0].downloadUris.windows = $null + + $packages = GetPackagesFromComponentsJson $componentsJson + + $packages | ConvertTo-Json -Compress | Should -Be "{}" + } + It 'given there are no windows versions, it returns an empty array' { $componentsJson.Packages[0].downloadUris.windows = @() @@ -206,6 +214,14 @@ Describe 'Gets The Versions' { $components | Should -Be @() } + It 'given the windowsVersions block is missing, it returns an empty array' { + $componentsJson.ContainerImages[0].windowsVersions = $null + + $components = GetComponentsFromComponentsJson $componentsJson + + $components | Should -Be @() + } + It 'given there is a latest version, it returns that version' { $componentsJson.ContainerImages[0].windowsVersions = @( [PSCustomObject]@{