fix logic test
This commit is contained in:
parent
9d2e048a4c
commit
697b268a92
@ -22,7 +22,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "PSGet",
|
"Name": "Existing",
|
||||||
"Modules": [
|
"Modules": [
|
||||||
"PowerShellGet"
|
"PowerShellGet"
|
||||||
]
|
]
|
||||||
|
@ -66,19 +66,16 @@ function Resolve-Dependency {
|
|||||||
else {
|
else {
|
||||||
Write-Warning ("Could not find the dependency file: {0}" -f $DepFilePath)
|
Write-Warning ("Could not find the dependency file: {0}" -f $DepFilePath)
|
||||||
}
|
}
|
||||||
$res = @()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$SelectedDependency = $Dependency.Optional | Where-Object {$_.Name -match $Name}
|
$SelectedDependency = $Dependency.Optional | Where-Object {$_.Name -match $Name}
|
||||||
|
$res = @()
|
||||||
foreach ($Module in $SelectedDependency.Modules) {
|
foreach ($Module in $SelectedDependency.Modules) {
|
||||||
$res += Test-Module -Name $Module
|
$res += Test-Module -Name $Module
|
||||||
}
|
}
|
||||||
if ($res.count -eq 0) {
|
# return false if there was not module at all
|
||||||
return $false
|
if (($res -contains $false) -or ($res.Count -eq 0)) {
|
||||||
}
|
|
||||||
elseif ($res -contains $false) {
|
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -44,7 +44,7 @@ Describe "Resolve-Dependency" {
|
|||||||
Context "Testing input variations" {
|
Context "Testing input variations" {
|
||||||
Mock Get-ModuleBase {return "{0}\resources" -f $PWD}
|
Mock Get-ModuleBase {return "{0}\resources" -f $PWD}
|
||||||
It "Should return true if all given dependencies exist" {
|
It "Should return true if all given dependencies exist" {
|
||||||
Resolve-Dependency -Name 'PSGet' | Should -Be $true
|
Resolve-Dependency -Name 'Existing' | Should -Be $true
|
||||||
}
|
}
|
||||||
It "Mixed results should return false" {
|
It "Mixed results should return false" {
|
||||||
Resolve-Dependency -Name 'PSGetMixed' | Should -Be $false
|
Resolve-Dependency -Name 'PSGetMixed' | Should -Be $false
|
||||||
|
Loading…
Reference in New Issue
Block a user