2023-11-15 12:12:28 +01:00
|
|
|
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
|
2023-11-28 02:25:03 +01:00
|
|
|
Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking
|
2023-11-15 12:12:28 +01:00
|
|
|
|
|
|
|
|
Describe "Powershell" {
|
|
|
|
|
Context "Powershell is installed" {
|
|
|
|
|
It "Powershell is installed" {
|
|
|
|
|
"pwsh -v" | Should -ReturnZeroExitCode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Context "Powershell Modules" {
|
2023-12-04 12:13:08 +01:00
|
|
|
$modules = (Get-ToolsetContent).powershellModules
|
2023-11-15 12:12:28 +01:00
|
|
|
$withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object {
|
|
|
|
|
@{moduleName = $_.name}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$withVersionsModules = $modules | Where-Object {$_.versions} | ForEach-Object {
|
|
|
|
|
$moduleName = $_.name
|
|
|
|
|
$_.versions | ForEach-Object {
|
|
|
|
|
@{moduleName = $moduleName; expectedVersion = $_}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-04 12:13:08 +01:00
|
|
|
|
2023-11-15 12:12:28 +01:00
|
|
|
It "<moduleName> is installed" -TestCases $withoutVersionsModules {
|
|
|
|
|
param (
|
|
|
|
|
[string] $moduleName
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
Get-Module -Name $moduleName -ListAvailable | Should -BeTrue
|
|
|
|
|
}
|
2023-12-04 12:13:08 +01:00
|
|
|
|
2023-11-15 12:12:28 +01:00
|
|
|
if ($withVersionsModules) {
|
|
|
|
|
It "<moduleName> with <expectedVersion> is installed" -TestCases $withVersionsModules {
|
|
|
|
|
param (
|
|
|
|
|
[string] $moduleName,
|
|
|
|
|
[string] $expectedVersion
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
(Get-Module -Name $moduleName -ListAvailable).Version -contains $expectedVersion | Should -BeTrue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-28 02:25:03 +01:00
|
|
|
}
|