Files
winutil/pester/win11creator.Tests.ps1
Chris Titus 104c763132 Fix Win11 Creator product-key validation failures (#4791)
* feat: Enhance Win11 Creator with edition ID handling and update autounattend.xml generation

* Strengthen Pester coverage for config and function files
2026-07-01 17:15:26 -05:00

34 lines
1.3 KiB
PowerShell

#===========================================================================
# Tests - Win11 Creator
#===========================================================================
Describe "Win11 Creator setup media" {
It "autounattend template does not force a product key" {
$templatePath = Join-Path $PSScriptRoot "..\tools\autounattend.xml"
[xml]$xml = Get-Content -Path $templatePath -Raw
$nsMgr = New-Object System.Xml.XmlNamespaceManager($xml.NameTable)
$nsMgr.AddNamespace("u", "urn:schemas-microsoft-com:unattend")
$productKeyCount = $xml.SelectNodes("//u:ProductKey", $nsMgr).Count
if ($productKeyCount -ne 0) {
throw "Expected no ProductKey nodes, found $productKeyCount."
}
}
It "ISO script accepts selected edition setup metadata" {
$isoScriptPath = Join-Path $PSScriptRoot "..\functions\private\Invoke-WinUtilISOScript.ps1"
$content = Get-Content -Path $isoScriptPath -Raw
foreach ($pattern in @(
'\[string\]\$InstallEditionId',
'\[int\]\$InstallImageIndex',
'sources\\ei\.cfg',
'PID\.txt'
)) {
if ($content -notmatch $pattern) {
throw "Expected Invoke-WinUtilISOScript.ps1 to match pattern: $pattern"
}
}
}
}