mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 14:17:22 +00:00
* first part * fix session manager plugin * rework AWS installation * azure cosmos db tests * azure devops cli * add azmodules test * put brackets * add root folder * remove validate aliyun * add azure modules * update modules test * docker, baze, dotnetsdk * DACFx * add azdevopscli * change to Should -BeTrue * nitpicks * remove extra * add azurecli * remove BeforeAll for DACFx * a bit of refactoring * fix templates * remove disk space validation * rename to powershell modules * fix templates
This commit is contained in:
44
images/win/scripts/Tests/PowerShellModules.Tests.ps1
Normal file
44
images/win/scripts/Tests/PowerShellModules.Tests.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
Describe "AzureModules" {
|
||||
$modules = (Get-ToolsetContent).azureModules
|
||||
$modulesRootPath = $env:PSMODULES_ROOT_FOLDER
|
||||
|
||||
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 {
|
||||
$testJob = Start-Job -ScriptBlock {
|
||||
param (
|
||||
$modulePath,
|
||||
$moduleName
|
||||
)
|
||||
|
||||
# Disable warning messages to prevent additional warnings about Az and Azurerm modules in the same session
|
||||
$WarningPreference = "SilentlyContinue"
|
||||
|
||||
$env:PsModulePath = "$modulePath;$env:PsModulePath"
|
||||
Import-Module -Name $moduleName
|
||||
(Get-Module -Name $moduleName).Version.ToString()
|
||||
|
||||
} -ArgumentList $modulePath, $moduleName
|
||||
|
||||
$moduleVersion = $testJob | Wait-Job | Receive-Job
|
||||
Remove-Job $testJob
|
||||
$moduleVersion | Should -Match $expectedVersion
|
||||
}
|
||||
}
|
||||
|
||||
if ($module.default) {
|
||||
$moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default }
|
||||
It "<moduleDefault> set as default" -TestCases $moduleInfo {
|
||||
$moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString()
|
||||
$moduleVersion | Should -Match $moduleDefault
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user