mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-19 00:06:45 +00:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
40
images/windows/scripts/tests/PowerShellAzModules.Tests.ps1
Normal file
40
images/windows/scripts/tests/PowerShellAzModules.Tests.ps1
Normal file
@@ -0,0 +1,40 @@
|
||||
Describe "AzureModules" {
|
||||
|
||||
$modules = (Get-ToolsetContent).azureModules
|
||||
$modulesRootPath = "C:\\Modules"
|
||||
|
||||
foreach ($module in $modules) {
|
||||
$moduleName = $module.name
|
||||
|
||||
Context "$moduleName" {
|
||||
|
||||
foreach ($version in $module.versions) {
|
||||
$modulePath = Join-Path -Path $modulesRootPath -ChildPath "${moduleName}_${version}"
|
||||
$moduleInfo = @{ moduleName = $moduleName; modulePath = $modulePath; expectedVersion = $version }
|
||||
It "<expectedVersion> exists in modules directory" -TestCases $moduleInfo {
|
||||
$ScriptBlock = {
|
||||
param ($modulePath, $moduleName)
|
||||
Import-Module ImageHelpers
|
||||
Get-ModuleVersionAsJob -modulePath $modulePath -moduleName $moduleName
|
||||
}
|
||||
if ($moduleName -eq "Az"){
|
||||
Start-Process -FilePath pwsh.exe -ArgumentList "-Command (Invoke-Command -ScriptBlock {$ScriptBlock} -ArgumentList $modulePath, $moduleName)" -Wait -PassThru
|
||||
} else {
|
||||
Start-Process -FilePath powershell.exe -ArgumentList "-Command (Invoke-Command -ScriptBlock {$ScriptBlock} -ArgumentList $modulePath, $moduleName)" -Wait -PassThru
|
||||
}
|
||||
$moduleVersion = Get-Content -Path "$env:TEMP\module-version.txt"
|
||||
Remove-Item -Path "${env:TEMP}\module-version.txt" -Force
|
||||
$moduleVersion | Should -Match $expectedVersion
|
||||
}
|
||||
}
|
||||
|
||||
if ($module.default) {
|
||||
$moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default }
|
||||
It "<moduleDefault> set as default" -TestCases $moduleInfo {
|
||||
$moduleVersions = Get-Module -ListAvailable -Name $moduleName | ForEach-Object { $_.Version.ToString() }
|
||||
$moduleVersions | Should -Contain $moduleDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user