Tests/Find-ModuleForInstall.tests.ps1
. $PSScriptRoot\..\Private\Find-ModuleForInstall.ps1 Describe 'OriAzBopBoostrapOriPsgallery\Find-ModuleForInstall' { Context 'Succesfull excution of Find Module' { Mock -CommandName Find-Module -Verifiable -MockWith { return @{ Name = $Name Version = [Version]1.0.0 } } Mock -CommandName Write-Verbose -Verifiable it 'Should be succesfully processed' { { $return = Find-ModuleForInstall ` -Name 'MyModule' ![string]::IsNullOrEmpty($return) | Should -BeExactly $true $return.Name -eq 'MyModule' | Should -BeExactly $true $return.Version -eq [Version]1.0.0 | Should -BeExactly $true } | Should -Not -Throw } Assert-MockCalled Write-Verbose -Times 1 -Exactly -ParameterFilter { $Message -eq "-- End of Find-ModuleForInstall --" } Assert-VerifiableMock } Context 'Succesfull excution of Find Module - No Module found' { Mock -CommandName Find-Module -Verifiable -MockWith { return $null } Mock -CommandName Write-Verbose -Verifiable it 'Should be succesfully processed' { { $return = Find-ModuleForInstall ` -Name 'MyModule' [string]::IsNullOrEmpty($return) | Should -BeExactly $true } | Should -Throw 'The module not found. Search criteria [{ "Name": "MyModule" }]' } Assert-MockCalled Write-Verbose -Times 0 -Exactly -ParameterFilter { $Message -eq "-- End of Find-ModuleForInstall --" } Assert-VerifiableMock } } |