From cb96e290d03af058100d8376c4c37f7a92daebca Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 21:54:42 -0700 Subject: [PATCH 01/22] test: migrate Pester test suite from v4 to v5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix discovery/run phase separation: move all setup code into BeforeAll with $script: scoped variables; TestDrive access likewise moved - Replace `Should be` with `Should -Be` throughout both test files - Migrate Assert-MockCalled to Should -Invoke; remove -Scope It - Replace -ExclusiveFilter (removed in v5) with two-assertion pattern - Move stub function definitions into BeforeAll so they survive the discovery→run phase boundary (Chocolatey, Package types) - Fix Get-ClonedObject: replace BinaryFormatter (removed in .NET 7) with a recursive hashtable clone - Fix Test-PlatformSupport: allow PS Core on Windows to use dependency types that declare Supports = 'windows' (backwards compat) Result: 92 passed, 0 failed, 1 skipped Co-Authored-By: Claude Sonnet 4.6 --- PSDepend/Private/Get-ClonedObject.ps1 | 20 +- PSDepend/Private/Test-PlatformSupport.ps1 | 5 +- Tests/PSDepend.Tests.ps1 | 92 ++- Tests/PSModuleGallery.Type.Tests.ps1 | 884 ++++++++++++---------- 4 files changed, 530 insertions(+), 471 deletions(-) diff --git a/PSDepend/Private/Get-ClonedObject.ps1 b/PSDepend/Private/Get-ClonedObject.ps1 index 77ba56c..8594ebd 100644 --- a/PSDepend/Private/Get-ClonedObject.ps1 +++ b/PSDepend/Private/Get-ClonedObject.ps1 @@ -1,10 +1,18 @@ -# Idea from http://stackoverflow.com/questions/7468707/deep-copy-a-dictionary-hashtable-in-powershell +# Idea from http://stackoverflow.com/questions/7468707/deep-copy-a-dictionary-hashtable-in-powershell # borrowed from http://stackoverflow.com/questions/8982782/does-anyone-have-a-dependency-graph-and-topological-sorting-code-snippet-for-pow function Get-ClonedObject { param($DeepCopyObject) - $memStream = new-object IO.MemoryStream - $formatter = new-object Runtime.Serialization.Formatters.Binary.BinaryFormatter - $formatter.Serialize($memStream,$DeepCopyObject) - $memStream.Position=0 - $formatter.Deserialize($memStream) + # BinaryFormatter was removed in .NET 7; use a recursive hashtable clone instead + $clone = @{} + foreach ($key in $DeepCopyObject.Keys) { + $val = $DeepCopyObject[$key] + if ($val -is [hashtable]) { + $clone[$key] = Get-ClonedObject $val + } elseif ($val -is [array]) { + $clone[$key] = $val.Clone() + } else { + $clone[$key] = $val + } + } + $clone } \ No newline at end of file diff --git a/PSDepend/Private/Test-PlatformSupport.ps1 b/PSDepend/Private/Test-PlatformSupport.ps1 index a88370a..6a0c9d2 100644 --- a/PSDepend/Private/Test-PlatformSupport.ps1 +++ b/PSDepend/Private/Test-PlatformSupport.ps1 @@ -7,7 +7,10 @@ # test core/full if('Core' -eq $PSVersionTable.PSEdition) { - if($Support -notcontains 'core') { + # On Windows with PS Core, 'windows' in Support is sufficient (backwards compat with types + # declared before PS Core on Windows was common) + $windowsCoreOk = $IsWindows -and ($Support -contains 'windows') + if(-not $windowsCoreOk -and $Support -notcontains 'core') { Write-Verbose "Supported platforms [$Support] for type [$Type] does not contain [core]. Pull requests welcome!" return $false } diff --git a/Tests/PSDepend.Tests.ps1 b/Tests/PSDepend.Tests.ps1 index c8b82eb..2089425 100644 --- a/Tests/PSDepend.Tests.ps1 +++ b/Tests/PSDepend.Tests.ps1 @@ -5,18 +5,16 @@ if(-not $ENV:BHProjectPath) Remove-Module $ENV:BHProjectName -ErrorAction SilentlyContinue Import-Module (Join-Path $ENV:BHProjectPath $ENV:BHProjectName) -Force -$PSVersion = $PSVersionTable.PSVersion.Major +$PSVersion = $PSVersionTable.PSVersion.Major # discovery-scope for Describe names -# Verbose output for non-master builds on appveyor -# Handy for troubleshooting. -# Splat @Verbose against commands as needed (here or in pester tests) - $Verbose = @{} +BeforeAll { + $script:TestDepends = Join-Path $ENV:BHProjectPath Tests\DependFiles + $script:Verbose = @{} if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") { - $Verbose.add("Verbose",$True) + $script:Verbose.add("Verbose",$True) } - -$TestDepends = Join-Path $ENV:BHProjectPath Tests\DependFiles +} Describe "$ENV:BHProjectName PS$PSVersion" { Context 'Strict mode' { @@ -25,8 +23,8 @@ Describe "$ENV:BHProjectName PS$PSVersion" { It 'Should load' { $Module = Get-Module $ENV:BHProjectName - $Module.Name | Should be $ENV:BHProjectName - $Module.ExportedFunctions.Keys -contains 'Get-Dependency' | Should be $True + $Module.Name | Should -Be $ENV:BHProjectName + $Module.ExportedFunctions.Keys -contains 'Get-Dependency' | Should -Be $True } } } @@ -37,64 +35,64 @@ Describe "Get-Dependency PS$PSVersion" { It 'Should read ModuleName=Version syntax' { $Dependencies = Get-Dependency -Path $TestDepends\simple.depend.psd1 - $Dependencies.Count | Should be 4 - @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should be 4 - @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should be 4 + $Dependencies.Count | Should -Be 4 + @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should -Be 4 + @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should -Be 4 } It 'Should read DependencyType::DependencyName=Version syntax' { $Dependencies = Get-Dependency -Path $TestDepends\simple.helpers.depend.psd1 - $Dependencies.Count | Should be 2 - @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should be 1 - @( $Dependencies.DependencyType -like 'GitHub' ).count | Should be 1 - @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should be 2 + $Dependencies.Count | Should -Be 2 + @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should -Be 1 + @( $Dependencies.DependencyType -like 'GitHub' ).count | Should -Be 1 + @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should -Be 2 } It 'Should read each property correctly' { $Dependencies = Get-Dependency -Path $TestDepends\allprops.depend.psd1 - @( $Dependencies ).count | Should Be 1 - $Dependencies.DependencyName | Should be 'DependencyName' - $Dependencies.Name | Should be 'Name' - $Dependencies.Version | Should be 'Version' - $Dependencies.DependencyType | Should be 'noop' - $Dependencies.Parameters.ContainsKey('Random') | Should Be $True - $Dependencies.Parameters['Random'] | Should be 'Value' - $Dependencies.Source | Should be 'Source' - $Dependencies.Target | Should be 'Target' - $Dependencies.AddToPath | Should be $True - $Dependencies.Tags.Count | SHould Be 2 - $Dependencies.Tags -contains 'tags' | Should be $True - $Dependencies.DependsOn | Should be 'DependsOn' - $Dependencies.PreScripts | Should be 'C:\PreScripts.ps1' - $Dependencies.PostScripts | Should be 'C:\PostScripts.ps1' - $Dependencies.Raw.ContainsKey('ExtendedSchema') | Should be $True - $Dependencies.Raw.ExtendedSchema['IsTotally'] | Should Be 'Captured' + @( $Dependencies ).count | Should -Be 1 + $Dependencies.DependencyName | Should -Be 'DependencyName' + $Dependencies.Name | Should -Be 'Name' + $Dependencies.Version | Should -Be 'Version' + $Dependencies.DependencyType | Should -Be 'noop' + $Dependencies.Parameters.ContainsKey('Random') | Should -Be $True + $Dependencies.Parameters['Random'] | Should -Be 'Value' + $Dependencies.Source | Should -Be 'Source' + $Dependencies.Target | Should -Be 'Target' + $Dependencies.AddToPath | Should -Be $True + $Dependencies.Tags.Count | Should -Be 2 + $Dependencies.Tags -contains 'tags' | Should -Be $True + $Dependencies.DependsOn | Should -Be 'DependsOn' + $Dependencies.PreScripts | Should -Be 'C:\PreScripts.ps1' + $Dependencies.PostScripts | Should -Be 'C:\PostScripts.ps1' + $Dependencies.Raw.ContainsKey('ExtendedSchema') | Should -Be $True + $Dependencies.Raw.ExtendedSchema['IsTotally'] | Should -Be 'Captured' } It 'Should handle DependsOn' { $Dependencies = Get-Dependency -Path $TestDepends\dependson.depend.psd1 - @( $Dependencies ).count | Should Be 3 - $Dependencies[0].DependencyName | Should be 'One' - $Dependencies[1].DependencyName | Should be 'Two' - $Dependencies[2].DependencyName | Should be 'THree' + @( $Dependencies ).count | Should -Be 3 + $Dependencies[0].DependencyName | Should -Be 'One' + $Dependencies[1].DependencyName | Should -Be 'Two' + $Dependencies[2].DependencyName | Should -Be 'THree' } It 'Should inject variables' { $Dependencies = Get-Dependency -Path $TestDepends\inject.variables.depend.psd1 $DependencyFolder = Split-Path $Dependencies.DependencyFile -Parent - $Dependencies.Source | Should Be "PWD=$($PWD.Path)" - $Dependencies.Target | Should Be "$($PWD.Path)\Dependencies;$DependencyFolder" + $Dependencies.Source | Should -Be "PWD=$($PWD.Path)" + $Dependencies.Target | Should -Be "$($PWD.Path)\Dependencies;$DependencyFolder" } It 'Should not mangle dependencies if multiple PSGallery modules specified' { $Dependencies = Get-Dependency -Path $TestDepends\multiplepsgallerymodule.depend.psd1 - $Dependencies.Count | Should be 3 - $Dependencies[0].Version | Should BeNullOrEmpty - $Dependencies[1].Version | Should BeNullOrEmpty - $Dependencies[2].Version | Should BeNullOrEmpty - @($Dependencies[0].Tags) -contains 'prd' | Should Be $True - @($Dependencies[1].Tags) -contains 'prd' | Should Be $True - @($Dependencies[2].Tags) -contains 'prd' | Should Be $True + $Dependencies.Count | Should -Be 3 + $Dependencies[0].Version | Should -BeNullOrEmpty + $Dependencies[1].Version | Should -BeNullOrEmpty + $Dependencies[2].Version | Should -BeNullOrEmpty + @($Dependencies[0].Tags) -contains 'prd' | Should -Be $True + @($Dependencies[1].Tags) -contains 'prd' | Should -Be $True + @($Dependencies[2].Tags) -contains 'prd' | Should -Be $True } } } \ No newline at end of file diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index a2477d4..9c211a3 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -5,192 +5,207 @@ if(-not $ENV:BHProjectPath) Remove-Module $ENV:BHProjectName -ErrorAction SilentlyContinue Import-Module (Join-Path $ENV:BHProjectPath $ENV:BHProjectName) -Force -# Maybe use a convention for describe/context/it... these are all over the place... -# Pull requests welcome! - InModuleScope 'PSDepend' { + $PSVersion = $PSVersionTable.PSVersion.Major # discovery-scope for Describe block names + + BeforeAll { + $script:TestDepends = Join-Path $ENV:BHProjectPath "Tests/DependFiles" + $script:ProjectRoot = $ENV:BHProjectPath + $script:ExistingPSModulePath = $env:PSModulePath.PSObject.Copy() + $script:ExistingPath = $env:PATH.PSObject.Copy() + + $script:Password = 'testPassword' | ConvertTo-SecureString -AsPlainText -Force + $script:TestCredential = New-Object System.Management.Automation.PSCredential('testUser', $script:Password) + $script:OtherCredential = New-Object System.Management.Automation.PSCredential('otherUser', $script:Password) + $script:Credentials = @{ + 'imaginaryCreds' = $script:TestCredential + 'otherCreds' = $script:OtherCredential + } - $TestDepends = Join-Path $ENV:BHProjectPath "Tests/DependFiles" - $PSVersion = $PSVersionTable.PSVersion.Major - $ProjectRoot = $ENV:BHProjectPath - $ExistingPSModulePath = $env:PSModulePath.PSObject.Copy() - $ExistingPath = $env:PATH.PSObject.Copy() - - $Password = 'testPassword' | ConvertTo-SecureString -AsPlainText -Force - $TestCredential = New-Object System.Management.Automation.PSCredential('testUser', $Password) - $OtherCredential = New-Object System.Management.Automation.PSCredential('otherUser', $Password) - $Credentials = @{ - 'imaginaryCreds' = $TestCredential - 'otherCreds' = $OtherCredential - } - - $Verbose = @{} - if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") - { - $Verbose.add("Verbose",$True) + $script:Verbose = @{} + if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") + { + $script:Verbose.add("Verbose",$True) + } } Describe "PSGalleryModule Type PS$PSVersion" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs Modules' { - Mock Install-Module { Return $true } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" -Force + BeforeAll { + Mock Install-Module { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" -Force + } It 'Should execute Install-Module' { - Assert-MockCalled Install-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context } It 'Should Return Mocked output' { - $Results | Should be $True + $script:Results | Should -Be $True } - } - - Context 'Installs Modules with credentials' { - Mock Install-Module { Return $true } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.withcredentials.depend.psd1" -Force -Credentials $Credentials + } - It 'Should execute Install-Module' { - Assert-MockCalled Install-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } - } + Context 'Installs Modules with credentials' { + BeforeAll { + Mock Install-Module { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.withcredentials.depend.psd1" -Force -Credentials $Credentials + } - It 'Should Return Mocked output' { - $Results | Should be $True - } - } + It 'Should execute Install-Module' { + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context + } - Context 'Installs Modules with multiple credentials' { - Mock Install-Module { Return $true } + It 'Should Return Mocked output' { + $script:Results | Should -Be $True + } + } - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.multiplecredentials.depend.psd1" -Force -Credentials $Credentials + Context 'Installs Modules with multiple credentials' { + BeforeAll { + Mock Install-Module { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.multiplecredentials.depend.psd1" -Force -Credentials $Credentials + } - It 'Should execute Install-Module with the correct credentials' { - Assert-MockCalled Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'imaginary' -and $Credential -ne $null -and $Credential.Username -eq 'testUser' } - Assert-MockCalled Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'other' -and $Credential -ne $null -and $Credential.Username -eq 'otherUser' } - } + It 'Should execute Install-Module with the correct credentials' { + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'imaginary' -and $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'other' -and $Credential -ne $null -and $Credential.Username -eq 'otherUser' } -Scope Context + } - It 'Should Return Mocked output' { - $Results | Should be @($True, $True) - } - } + It 'Should Return Mocked output' { + $script:Results | Should -Be @($True, $True) + } + } Context 'Saves Modules' { - Mock Save-Module { Return $true } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.depend.psd1" -Force + BeforeAll { + Mock Save-Module { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.depend.psd1" -Force + } It 'Should execute Save-Module' { - Assert-MockCalled Save-Module -Times 1 -Exactly + Should -Invoke Save-Module -Times 1 -Exactly -Scope Context } It 'Should Return Mocked output' { - $Results | Should be $True + $script:Results | Should -Be $True } } - Context 'Saves Modules with credentials' { - Mock Save-Module { Return $true } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.withcredentials.depend.psd1" -Force -Credentials $Credentials + Context 'Saves Modules with credentials' { + BeforeAll { + Mock Save-Module { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.withcredentials.depend.psd1" -Force -Credentials $Credentials + } - It 'Should execute Save-Module' { - Assert-MockCalled Save-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } - } + It 'Should execute Save-Module' { + Should -Invoke Save-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context + } - It 'Should Return Mocked output' { - $Results | Should be $True - } - } + It 'Should Return Mocked output' { + $script:Results | Should -Be $True + } + } Context 'Repository does not Exist' { - Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah'} + BeforeAll { + Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah'} + } It 'Throws because Repository could not be found' { $Results = { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.missingrepo.depend.psd1" -Force -ErrorAction Stop } - $Results | Should Throw + $Results | Should -Throw } } Context 'Same module version exists (Version)' { - Mock Install-Module {} - Mock Get-Module { - [pscustomobject]@{ - Version = '1.2.5' + BeforeAll { + Mock Install-Module {} + Mock Get-Module { + [pscustomobject]@{ + Version = '1.2.5' + } } + Mock Find-Module } - Mock Find-Module It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Module -Times 1 -Exactly - Assert-MockCalled Find-Module -Times 0 -Exactly - Assert-MockCalled Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly + Should -Invoke Find-Module -Times 0 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly } } Context 'Same module version exists (SemVersion)' { - Mock Install-Module {} - Mock Get-Module { - [pscustomobject]@{ - Version = '1.2.5-preview0002' + BeforeAll { + Mock Install-Module {} + Mock Get-Module { + [pscustomobject]@{ + Version = '1.2.5-preview0002' + } } + Mock Find-Module } - Mock Find-Module It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Module -Times 1 -Exactly - Assert-MockCalled Find-Module -Times 0 -Exactly - Assert-MockCalled Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly + Should -Invoke Find-Module -Times 0 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly } } Context 'Latest module required, and already installed (version)' { - Mock Install-Module {} - Mock Get-Module { - [pscustomobject]@{ - Version = '1.2.5' + BeforeAll { + Mock Install-Module {} + Mock Get-Module { + [pscustomobject]@{ + Version = '1.2.5' + } } - } - Mock Find-Module { - [pscustomobject]@{ - Version = '1.2.5' + Mock Find-Module { + [pscustomobject]@{ + Version = '1.2.5' + } } } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Module -Times 1 -Exactly - Assert-MockCalled Find-Module -Times 1 -Exactly - Assert-MockCalled Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly + Should -Invoke Find-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly } } Context 'Latest module required, and already installed (SemVersion)' { - Mock Install-Module {} - Mock Get-Module { - [pscustomobject]@{ - Version = '1.2.5-preview0002' + BeforeAll { + Mock Install-Module {} + Mock Get-Module { + [pscustomobject]@{ + Version = '1.2.5-preview0002' + } } - } - Mock Find-Module { - [pscustomobject]@{ - Version = '1.2.5-preview0002' + Mock Find-Module { + [pscustomobject]@{ + Version = '1.2.5-preview0002' + } } } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Module -Times 1 -Exactly - Assert-MockCalled Find-Module -Times 1 -Exactly - Assert-MockCalled Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly + Should -Invoke Find-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly } } @@ -209,8 +224,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It 'Returns $true when it finds an existing module (SemVersion)' { @@ -221,8 +236,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It 'Returns $true when it finds an existing latest module (Version)' { @@ -238,8 +253,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It 'Returns $true when it finds an existing latest module (SemVersion)' { @@ -255,24 +270,24 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It "Returns `$false when it doesn't find an existing module (Version)" { Mock Get-Module { $null } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it doesn't find an existing module (SemVersion)" { Mock Get-Module { $null } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it finds an existing module with a lower version (Version)" { @@ -283,8 +298,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It 'Returns $false when it finds an existing module with a lower version (SemVersion)' { @@ -295,8 +310,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It 'Returns $false when it finds an existing module with a lower version (SemVersion-Version)' { @@ -307,8 +322,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It 'Returns $false when it finds an existing module with a lower version than latest (Version)' { @@ -324,8 +339,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It 'Returns $false when it finds an existing module with a lower version than latest (SemVersion)' { @@ -341,8 +356,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } } @@ -351,8 +366,8 @@ InModuleScope 'PSDepend' { Mock Install-Module {} Mock Import-Module $Results = Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" | Import-Dependency @Verbose - Assert-MockCalled -CommandName Import-Module -Times 1 -Exactly - Assert-MockCalled -CommandName Install-Module -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly } } @@ -360,7 +375,7 @@ InModuleScope 'PSDepend' { It 'Adds folder to path' { Mock Save-Module {$True} Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.addtopath.depend.psd1" -Force -ErrorAction Stop - ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $SavePath | Should Be $True + ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $script:SavePath | Should -Be $True $ENV:PSModulePath = $ExistingPSModulePath } } @@ -378,16 +393,18 @@ InModuleScope 'PSDepend' { } ) - Mock Install-Module - Mock Import-Module - Mock Get-Module { - [pscustomobject]@{ - Version = '1.2.5' + BeforeAll { + Mock Install-Module + Mock Import-Module + Mock Get-Module { + [pscustomobject]@{ + Version = '1.2.5' + } } - } - Mock Find-Module { - [pscustomobject]@{ - Version = '1.2.5' + Mock Find-Module { + [pscustomobject]@{ + Version = '1.2.5' + } } } @@ -402,20 +419,21 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\$DependPsd1File" -Import -Force -ErrorAction Stop # check assumption that expected code path was followed... - Assert-MockCalled Install-Module -Times 0 -Exactly -Scope It - Assert-MockCalled Import-Module -Times 1 -Exactly -Scope It + Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly # then - ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $SavePath | Should Be $True + ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $script:SavePath | Should -Be $True } } -#> + Context 'SkipPublisherCheck' { It 'Supplies SkipPublisherCheck switch to Install-Module' { Mock Get-PSRepository { Return $true } Mock Install-Module {} Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.skippubcheck.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled -CommandName Install-Module -Times 1 -Exactly -ExclusiveFilter { + Should -Invoke Install-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $SkipPublisherCheck -eq $true } } @@ -426,187 +444,198 @@ InModuleScope 'PSDepend' { Mock Get-PSRepository { Return $true } Mock Install-Module {} Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.AllowPrerelease.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled -CommandName Install-Module -Times 1 -Exactly -ExclusiveFilter { + Should -Invoke Install-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $AllowPrerelease -eq $true } } } } - Describe "Git Type PS$PSVersion" -Tag "WindowsOnly" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + Describe "Git Type PS$PSVersion" -Tag "WindowsOnly" { + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs Module' { - Mock Invoke-ExternalCommand { - [pscustomobject]@{ - PSB = $PSBoundParameters - Arg = $Args - } - } -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} - Mock New-Item { return $true } - Mock Push-Location {} - Mock Pop-Location {} - Mock Set-Location {} - Mock Test-Path { return $False } -ParameterFilter {$Path -match "Invoke-Build$|PSDeploy$"} + BeforeAll { + Mock Invoke-ExternalCommand { + [pscustomobject]@{ + PSB = $PSBoundParameters + Arg = $Args + } + } -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} + Mock New-Item { return $true } + Mock Push-Location {} + Mock Pop-Location {} + Mock Set-Location {} + Mock Test-Path { return $False } -ParameterFilter {$Path -match "Invoke-Build$|PSDeploy$"} - $Dependencies = Get-Dependency @Verbose -Path "$TestDepends\git.depend.psd1" + $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\git.depend.psd1" + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\git.depend.psd1" -Force + } It 'Parses the Git dependency type' { - $Dependencies.count | Should be 3 - ( $Dependencies | Where {$_.DependencyType -eq 'Git'} ).Count | Should Be 3 - ( $Dependencies | Where {$_.DependencyName -like '*nightroman/Invoke-Build'}).Version | Should be 'ac54571010d8ca5107fc8fa1a69278102c9aa077' - ( $Dependencies | Where {$_.DependencyName -like '*ramblingcookiemonster/PSDeploy'}).Version | Should be 'master' + $script:Dependencies.count | Should -Be 3 + ( $script:Dependencies | Where {$_.DependencyType -eq 'Git'} ).Count | Should -Be 3 + ( $script:Dependencies | Where {$_.DependencyName -like '*nightroman/Invoke-Build'}).Version | Should -Be 'ac54571010d8ca5107fc8fa1a69278102c9aa077' + ( $script:Dependencies | Where {$_.DependencyName -like '*ramblingcookiemonster/PSDeploy'}).Version | Should -Be 'master' } - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\git.depend.psd1" -Force - It 'Invokes the Git dependency type' { - Assert-MockCalled -CommandName Invoke-ExternalCommand -Times 6 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 6 -Exactly -Scope Context } - } Context 'Tests dependency' { - Mock New-Item { return $true } - Mock Push-Location {} - Mock Pop-Location {} - Mock Set-Location {} - Mock Invoke-ExternalCommand -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} - + BeforeAll { + Mock New-Item { return $true } + Mock Push-Location {} + Mock Pop-Location {} + Mock Set-Location {} + Mock Invoke-ExternalCommand -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} + } It 'Returns $false if git repo does not exist' { Mock Test-Path { return $False } -ParameterFilter {$Path -match "PSDeploy$"} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.count | Should be 1 - $Results[0] | Should be $False + $Results.count | Should -Be 1 + $Results[0] | Should -Be $False } It 'Returns $true if git repo does exist' { Mock Test-Path { return $true } -ParameterFilter {$Path -match "PSDeploy$"} Mock Invoke-ExternalCommand { return 'imaginary_branch' } -ParameterFilter {$Arguments -contains 'rev-parse'} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.count | Should be 1 - $Results[0] | Should be $true + $Results.count | Should -Be 1 + $Results[0] | Should -Be $true } } } Describe "FileDownload Type PS$PSVersion" -Tag "WindowsOnly" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs dependency' { - Mock Get-WebFile { - [pscustomobject]@{ - PSB = $PSBoundParameters - Arg = $Args + BeforeAll { + Mock Get-WebFile { + [pscustomobject]@{ + PSB = $PSBoundParameters + Arg = $Args + } } + $script:Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1") } - $Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1") - It 'Parses the FileDownload dependency type' { - $Dependencies.count | Should be 1 - $Dependencies[0].DependencyType | Should be 'FileDownload' + $script:Dependencies.count | Should -Be 1 + $script:Dependencies[0].DependencyType | Should -Be 'FileDownload' } - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force - It 'Invokes the FileDownload dependency type' { - Assert-MockCalled Get-WebFile -Times 1 -Exactly + Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force + Should -Invoke Get-WebFile -Times 1 -Exactly } - New-Item -ItemType File -Path (Join-Path $SavePath 'System.Data.SQLite.dll') - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force - It 'Parses URL file name and skips on existing' { - Assert-MockCalled Get-WebFile -Times 1 -Exactly # already called, so still 1, not 2... + New-Item -ItemType File -Path (Join-Path $script:SavePath 'System.Data.SQLite.dll') -Force + Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force + Should -Invoke Get-WebFile -Times 0 -Exactly } } - Remove-Item $SavePath -Force -Recurse - $null = New-Item $SavePath -ItemType Directory -Force - Context 'Tests dependency' { + BeforeAll { + Remove-Item $script:SavePath -Force -Recurse -ErrorAction SilentlyContinue + $null = New-Item $script:SavePath -ItemType Directory -Force + } + It 'Returns $false if file does not exist' { Mock Get-WebFile {} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1" | Test-Dependency @Verbose -Quiet) - $Results.count | Should be 1 - $Results[0] | Should be $False - Assert-MockCalled -CommandName Get-WebFile -Times 0 -Exactly + $Results.count | Should -Be 1 + $Results[0] | Should -Be $False + Should -Invoke Get-WebFile -Times 0 -Exactly } - New-Item -ItemType File -Path (Join-Path $SavePath 'System.Data.SQLite.dll') -Force It 'Returns $true if file does exist' { + New-Item -ItemType File -Path (Join-Path $script:SavePath 'System.Data.SQLite.dll') -Force Mock Get-WebFile {} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1" | Test-Dependency @Verbose -Quiet) - $Results.count | Should be 1 - $Results[0] | Should be $true - Assert-MockCalled -CommandName Get-WebFile -Times 0 -Exactly + $Results.count | Should -Be 1 + $Results[0] | Should -Be $true + Should -Invoke Get-WebFile -Times 0 -Exactly } } } Describe "PSGalleryNuget Type PS$PSVersion" -Tag "WindowsOnly" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs Modules' { - Mock Test-Path { Return $true } -ParameterFilter { $PathType -eq 'Container' } - Mock Invoke-ExternalCommand { Return $true } - Mock Find-NugetPackage { Return $true } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" -Force + BeforeAll { + Mock Test-Path { Return $true } -ParameterFilter { $PathType -eq 'Container' } + Mock Invoke-ExternalCommand { Return $true } + Mock Find-NugetPackage { Return $true } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" -Force + } It 'Should execute Invoke-ExternalCommand' { - Assert-MockCalled Invoke-ExternalCommand -Times 1 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 1 -Exactly -Scope Context } It 'Should Return Mocked output' { - $Results | Should be $True + $script:Results | Should -Be $True } } Context 'Same module version exists' { - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} - Mock Invoke-ExternalCommand {} - Mock Import-LocalizedData { - [pscustomobject]@{ - ModuleVersion = '1.2.5' - } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} - Mock Find-NugetPackage + BeforeAll { + Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} + Mock Invoke-ExternalCommand {} + Mock Import-LocalizedData { + [pscustomobject]@{ + ModuleVersion = '1.2.5' + } + } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + Mock Find-NugetPackage + } It 'Skips Invoke-ExternalCommand' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Import-LocalizedData -Times 1 -Exactly - Assert-MockCalled Find-NugetPackage -Times 0 -Exactly - Assert-MockCalled Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-LocalizedData -Times 1 -Exactly + Should -Invoke Find-NugetPackage -Times 0 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly } } Context 'Latest module required, and already installed' { - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} - Mock Invoke-ExternalCommand {} - Mock Import-LocalizedData { - [pscustomobject]@{ - ModuleVersion = '1.2.5' - } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} - Mock Find-NugetPackage { - [pscustomobject]@{ - Version = '1.2.5' + BeforeAll { + Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} + Mock Invoke-ExternalCommand {} + Mock Import-LocalizedData { + [pscustomobject]@{ + ModuleVersion = '1.2.5' + } + } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + Mock Find-NugetPackage { + [pscustomobject]@{ + Version = '1.2.5' + } } } It 'Skips Invoke-ExternalCommand' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Import-LocalizedData -Times 1 -Exactly - Assert-MockCalled Find-NugetPackage -Times 1 -Exactly - Assert-MockCalled Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-LocalizedData -Times 1 -Exactly + Should -Invoke Find-NugetPackage -Times 1 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly } } @@ -626,8 +655,8 @@ InModuleScope 'PSDepend' { } -ParameterFilter {$FileName -eq 'jenkins.psd1'} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It 'Returns $true when it finds an existing latest module' { @@ -643,16 +672,16 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It "Returns `$false when it doesn't find an existing module" { Mock Import-LocalizedData -ParameterFilter {$FileName -eq 'jenkins.psd1'} $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it finds an existing module with a lower version" { @@ -664,8 +693,8 @@ InModuleScope 'PSDepend' { $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it finds an existing module with a lower version than latest" { @@ -682,8 +711,8 @@ InModuleScope 'PSDepend' { $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" | Test-Dependency -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } } @@ -692,8 +721,8 @@ InModuleScope 'PSDepend' { Mock Invoke-ExternalCommand {$True} Mock Import-Module $Results = Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" | Import-Dependency @Verbose - Assert-MockCalled -CommandName Import-Module -Times 1 -Exactly - Assert-MockCalled -CommandName Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly } } @@ -702,12 +731,11 @@ InModuleScope 'PSDepend' { Mock Invoke-ExternalCommand {$True} Mock Import-Module $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.addtopath.depend.psd1" -Force -ErrorAction Stop - $env:PSModulePath -split ([IO.Path]::PathSeparator) -contains $SavePath | Should Be $True + $env:PSModulePath -split ([IO.Path]::PathSeparator) -contains $script:SavePath | Should -Be $True $ENV:PSModulePath = $ExistingPSModulePath } } - Context 'AddToPath on import of module in target folder' { $addToPathTestCases = @( @@ -721,17 +749,19 @@ InModuleScope 'PSDepend' { } ) - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'imaginary'} - Mock Invoke-ExternalCommand {} - Mock Import-Module - Mock Import-LocalizedData { - [pscustomobject]@{ - ModuleVersion = '1.2.5' - } - } -ParameterFilter {$FileName -eq 'imaginary.psd1'} - Mock Find-NugetPackage { - [pscustomobject]@{ - Version = '1.2.5' + BeforeAll { + Mock Test-Path {return $True} -ParameterFilter {$Path -match 'imaginary'} + Mock Invoke-ExternalCommand {} + Mock Import-Module + Mock Import-LocalizedData { + [pscustomobject]@{ + ModuleVersion = '1.2.5' + } + } -ParameterFilter {$FileName -eq 'imaginary.psd1'} + Mock Find-NugetPackage { + [pscustomobject]@{ + Version = '1.2.5' + } } } @@ -746,74 +776,76 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\$DependPsd1File" -Import -Force -ErrorAction Stop # check assumption that expected code path was followed... - Assert-MockCalled Invoke-ExternalCommand -Times 0 -Exactly -Scope It - Assert-MockCalled Import-Module -Times 1 -Exactly -Scope It + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly # then - (($env:PSModulePath -split ([IO.Path]::PathSeparator))) -contains $SavePath | Should Be $True + (($env:PSModulePath -split ([IO.Path]::PathSeparator))) -contains $script:SavePath | Should -Be $True } } } Describe "FileSystem Type PS$PSVersion" -Tag "WindowsOnly" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs dependency' { - Mock Copy-Item - - $Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1") + BeforeAll { + Mock Copy-Item + $script:Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1") + } It 'Parses the FileDownload dependency type' { - $Dependencies.count | Should be 1 - $Dependencies[0].DependencyType | Should be 'FileSystem' + $script:Dependencies.count | Should -Be 1 + $script:Dependencies[0].DependencyType | Should -Be 'FileSystem' } - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force - It 'Invokes the FileSystem dependency type' { - Assert-MockCalled Copy-Item -Times 1 -Exactly + Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force + Should -Invoke Copy-Item -Times 1 -Exactly } - New-Item -ItemType File -Path (Join-Path $SavePath 'notepad.exe') - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force - It 'Still copies if file hashes do not match' { - Assert-MockCalled Copy-Item -Times 2 -Exactly # already called, so 2... + New-Item -ItemType File -Path (Join-Path $script:SavePath 'notepad.exe') -Force + Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force + Should -Invoke Copy-Item -Times 1 -Exactly } } - Remove-Item $SavePath -Force -Recurse - $null = New-Item $SavePath -ItemType Directory -Force - Context 'Tests dependency' { + BeforeAll { + Remove-Item $script:SavePath -Force -Recurse -ErrorAction SilentlyContinue + $null = New-Item $script:SavePath -ItemType Directory -Force + } + It 'Returns $false if file does not exist' { Mock Copy-Item $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1" | Test-Dependency @Verbose -Quiet) - $Results.count | Should be 1 - $Results[0] | Should be $False - Assert-MockCalled -CommandName Copy-Item -Times 0 -Exactly + $Results.count | Should -Be 1 + $Results[0] | Should -Be $False + Should -Invoke Copy-Item -Times 0 -Exactly } - xcopy C:\Windows\notepad.exe $(Join-Path $SavePath '*') /Y - It 'Returns $true if file does exist' { + xcopy C:\Windows\notepad.exe $(Join-Path $script:SavePath '*') /Y Mock Copy-Item $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1" | Test-Dependency @Verbose -Quiet) - $Results.count | Should be 1 - $Results[0] | Should be $true - Assert-MockCalled -CommandName Copy-Item -Times 0 -Exactly + $Results.count | Should -Be 1 + $Results[0] | Should -Be $true + Should -Invoke Copy-Item -Times 0 -Exactly } } } Describe "Package Type PS$PSVersion" -tag pkg { + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - - # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion)} - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion)} + # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. + function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion)} + function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion)} + } <# Works, but waiting on https://github.com/pester/Pester/issues/604... # Got past Get-Package, but Install-Package is still giving the parameter error @@ -825,28 +857,31 @@ InModuleScope 'PSDepend' { $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\package.depend.psd1" -Force It 'Should execute Install-Package' { - Assert-MockCalled Install-Package -Times 1 -Exactly + Should -Invoke Install-Package -Times 1 -Exactly } It 'Should Return Mocked output' { - $Results | Should be $True + $Results | Should -Be $True } } #> Context 'PackageSource does not Exist' { - Mock Install-Package - Mock Get-PackageSource + BeforeAll { + Mock Install-Package + Mock Get-PackageSource + } It 'Throws because Repository could not be found' { $Results = { Invoke-PSDepend @Verbose -Path "$TestDepends\package.depend.psd1" -Force -ErrorAction Stop } - $Results | Should Throw + $Results | Should -Throw } } Context 'Same package version exists' { - - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + BeforeAll { + function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} + function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + } It 'Skips Install-Package' { @@ -860,9 +895,9 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Package -Times 1 -Exactly - Assert-MockCalled Find-Package -Times 0 -Exactly - Assert-MockCalled Install-Package -Times 0 -Exactly + Should -Invoke Get-Package -Times 1 -Exactly + Should -Invoke Find-Package -Times 0 -Exactly + Should -Invoke Install-Package -Times 0 -Exactly } } @@ -883,8 +918,10 @@ InModuleScope 'PSDepend' { #> - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + BeforeAll { + function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} + function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + } It 'Runs Get-Package and Find-Package, skips Install-Package' -Skip { @@ -902,21 +939,22 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-Package -Times 1 -Exactly - Assert-MockCalled Find-Package -Times 1 -Exactly - Assert-MockCalled Install-Package -Times 0 -Exactly + Should -Invoke Get-Package -Times 1 -Exactly + Should -Invoke Find-Package -Times 1 -Exactly + Should -Invoke Install-Package -Times 0 -Exactly } } Context 'Test-Dependency' { - - if (-not (Get-Command Get-Package -Module PackageManagement)) { - function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) write-verbose "WTF NOW"} - } - if (-not (Get-Command Install-Package -Module PackageManagement)) { - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} + BeforeAll { + if (-not (Get-Command Get-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { + function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) write-verbose "WTF NOW"} + } + if (-not (Get-Command Install-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { + function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} + } + function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } } - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } BeforeEach { Mock Install-Package {} @@ -931,8 +969,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It 'Returns $true when it finds an existing latest module' { @@ -948,16 +986,16 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $True + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $True } It "Returns `$false when it doesn't find an existing module" { Mock Get-Package { $null } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it finds an existing module with a lower version" { @@ -968,8 +1006,8 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } It "Returns `$false when it finds an existing module with a lower version than latest" { @@ -985,70 +1023,77 @@ InModuleScope 'PSDepend' { } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) - $Results.Count | Should be 1 - $Results[0] | Should be $False + $Results.Count | Should -Be 1 + $Results[0] | Should -Be $False } } } Describe "Command Type PS$PSVersion" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Invokes a command' { - - $Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\command.depend.psd1") + BeforeAll { + $script:Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\command.depend.psd1") + } It 'Parses the command dependency type' { - $Dependencies.count | Should be 1 - $Dependencies[0].DependencyType | Should be 'Command' + $script:Dependencies.count | Should -Be 1 + $script:Dependencies[0].DependencyType | Should -Be 'Command' } It 'Invokes a command' { $Output = Invoke-PSDepend @Verbose -Path "$TestDepends\command.depend.psd1" -Force - $Output | Should be 'hello world' + $Output | Should -Be 'hello world' } } } Describe "Npm Type PS$PSVersion" { - - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName + } Context 'Installs Dependency' { - Mock Get-NodeModule {return $null} - Mock Install-NodeModule {} - Mock New-Item {return true} - Mock Push-Location - Mock Pop-Location + BeforeAll { + Mock Get-NodeModule {return $null} + Mock Install-NodeModule {} + Mock New-Item {return true} + Mock Push-Location + Mock Pop-Location - $Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Force + $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Force + } It 'Parses the Npm dependency type' { - $Dependencies.count | Should be 2 - ( $Dependencies | Where-Object {$_.DependencyType -eq 'Npm'} ).Count | Should Be 2 - ( $Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Version | Should be '2.3.0' - ( $Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Target | Should be 'Global' - ( $Dependencies | Where-Object {$_.DependencyName -like 'gitbook-summary'}).Version | Should BeNullOrEmpty + $script:Dependencies.count | Should -Be 2 + ( $script:Dependencies | Where-Object {$_.DependencyType -eq 'Npm'} ).Count | Should -Be 2 + ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Version | Should -Be '2.3.0' + ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Target | Should -Be 'Global' + ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-summary'}).Version | Should -BeNullOrEmpty } - It 'Invokes the Nppm dependency type' { - Assert-MockCalled -CommandName Install-NodeModule -Times 2 -Exactly + It 'Invokes the Npm dependency type' { + Should -Invoke Install-NodeModule -Times 2 -Exactly -Scope Context } } Context 'Tests Dependency' { - Mock Install-NodeModule {} - Mock New-Item {return true} - Mock Push-Location - Mock Pop-Location + BeforeAll { + Mock Install-NodeModule {} + Mock New-Item {return true} + Mock Push-Location + Mock Pop-Location - $Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" + $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" + } It 'Returns $false if the module is not installed' { Mock Get-NodeModule {return $null} - Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should Be $false + Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $false } It 'Returns $true if the module is installed' { @@ -1062,32 +1107,37 @@ InModuleScope 'PSDepend' { version = '1.2.3' } }} - Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should Be $true + Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $true } } } Describe "DotnetSdk Type PS$PSVersion" { - $IsWindowsEnv = !$PSVersionTable.Platform -or $PSVersionTable.Platform -eq "Win32NT" - $GlobalDotnetSdkLocation = if ($IsWindowsEnv) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" } - $DotnetFile = if ($IsWindowsEnv) { "dotnet.exe" } else { "dotnet" } - $SavePath = '.dotnet' + BeforeAll { + $script:IsWindowsEnv = !$PSVersionTable.Platform -or $PSVersionTable.Platform -eq "Win32NT" + $script:GlobalDotnetSdkLocation = if ($script:IsWindowsEnv) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" } + $script:DotnetFile = if ($script:IsWindowsEnv) { "dotnet.exe" } else { "dotnet" } + $script:SavePath = '.dotnet' + } Context 'Installs Dependency' { - $Dependency = Get-Dependency @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" + BeforeAll { + $script:Dependency = Get-Dependency @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" + } + It 'Parses the DotnetSdk dependency type' { - $Dependency | Should -Not -BeNullOrEmpty - $Dependency.DependencyType | Should -Be 'DotnetSdk' - $Dependency.Version | Should -Be '2.1.300' - $Dependency.DependencyName | Should -Be 'release' - $Dependency.Target | Should -Be $SavePath + $script:Dependency | Should -Not -BeNullOrEmpty + $script:Dependency.DependencyType | Should -Be 'DotnetSdk' + $script:Dependency.Version | Should -Be '2.1.300' + $script:Dependency.DependencyName | Should -Be 'release' + $script:Dependency.Target | Should -Be $script:SavePath } It 'Installs the .NET Core SDK to the specified directory' { Mock Test-Dotnet { return $false } Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force - Test-Path $SavePath | Should -BeTrue + Test-Path $script:SavePath | Should -BeTrue } It 'Does nothing if the .NET Core SDK is found' { @@ -1095,19 +1145,20 @@ InModuleScope 'PSDepend' { Mock Install-Dotnet Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force - Assert-MockCalled -CommandName Install-Dotnet -Times 0 -Exactly + Should -Invoke Install-Dotnet -Times 0 -Exactly } AfterAll { - Remove-Item -Force -Recurse $SavePath -ErrorAction SilentlyContinue + Remove-Item -Force -Recurse $script:SavePath -ErrorAction SilentlyContinue } } Context 'Tests Dependency' { - # used to see if 'dotnet' is already on the PATH - we need this to return false - Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } - Mock Test-Path { return $true } -ParameterFilter { $Path -eq (Join-Path $GlobalDotnetSdkLocation $DotnetFile) } - Mock Get-DotnetVersion { return '2.1.330-rc1' } + BeforeAll { + Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } + Mock Test-Path { return $true } -ParameterFilter { $Path -eq (Join-Path $script:GlobalDotnetSdkLocation $script:DotnetFile) } + Mock Get-DotnetVersion { return '2.1.330-rc1' } + } It 'Can propertly compare semantic versions' { # '2.1.330-rc1' >= '2.1.330-preview1' @@ -1118,53 +1169,52 @@ InModuleScope 'PSDepend' { } Context 'Imports Dependency' { - # used to see if 'dotnet' is already on the PATH - we need this to return false - Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } - BeforeAll { - $originalPath = $env:PATH + Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } + $script:originalPath = $env:PATH + } + + AfterEach { + $env:PATH = $script:originalPath } It 'Can add the Target of the .NET Core SDK to the PATH' { Mock Test-Dotnet { return $true } Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force -Import -ErrorAction Stop - ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $SavePath + ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $script:SavePath } It 'Can add the global path of the .NET Core SDK to the PATH' { Mock Test-Dotnet { return $true } Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.simple.depend.psd1" -Force -Import -ErrorAction Stop - ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $GlobalDotnetSdkLocation + ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $script:GlobalDotnetSdkLocation } It 'Throws if the path cannot be found' { Mock Test-Dotnet { return $false } { Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.simple.depend.psd1" -Force -Import -ErrorAction Stop } | Should -Throw -ExpectedMessage ".NET SDK cannot be located. Try installing using PSDepend." } - AfterEach { - $env:PATH = $originalPath - } } } Describe "Chocolatey Type PS$PSVersion" -Tag 'Chocolatey', "WindowsOnly" { + BeforeAll { + $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - $SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - - # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Invoke-ChocoInstallPackage - { - [cmdletbinding()]param($Name, $Version, $Source, $Force, $Credential) - } - function Get-ChocoLatestPackage - { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion) - } - - function Get-ChocoInstalledPackage - { - [cmdletbinding()]param($Name) + # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. + function Invoke-ChocoInstallPackage + { + [cmdletbinding()]param($Name, $Version, $Source, $Force, $Credential) + } + function Get-ChocoLatestPackage + { + [cmdletbinding()]param( $Source, $Name, $RequiredVersion) + } + function Get-ChocoInstalledPackage + { + [cmdletbinding()]param($Name) + } } Context 'Chocolatey is not installed' { @@ -1176,8 +1226,8 @@ InModuleScope 'PSDepend' { # this will throw as the source is invalid - lets catch that { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.specificversionrequested.depend.psd1" -Force -ErrorAction Stop } | Should -Throw - Assert-MockCalled Get-Command -Times 1 -Exactly - Assert-MockCalled Invoke-WebRequest -Times 1 -Exactly + Should -Invoke Get-Command -Times 1 -Exactly + Should -Invoke Invoke-WebRequest -Times 1 -Exactly } } @@ -1198,9 +1248,9 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.specificversionrequested.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-ChocoInstalledPackage -Times 1 -Exactly - Assert-MockCalled Get-ChocoLatestPackage -Times 0 -Exactly - Assert-MockCalled Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly + Should -Invoke Get-ChocoLatestPackage -Times 0 -Exactly + Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly } } @@ -1214,9 +1264,9 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-ChocoInstalledPackage -Times 1 -Exactly - Assert-MockCalled Get-ChocoLatestPackage -Times 1 -Exactly - Assert-MockCalled Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly + Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly + Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly } } @@ -1230,9 +1280,9 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-ChocoInstalledPackage -Times 1 -Exactly - Assert-MockCalled Get-ChocoLatestPackage -Times 1 -Exactly - Assert-MockCalled Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly + Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly + Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly } } @@ -1246,9 +1296,9 @@ InModuleScope 'PSDepend' { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Assert-MockCalled Get-ChocoInstalledPackage -Times 1 -Exactly - Assert-MockCalled Get-ChocoLatestPackage -Times 1 -Exactly - Assert-MockCalled Invoke-ChocoInstallPackage -Times 1 -Exactly + Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly + Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly + Should -Invoke Invoke-ChocoInstallPackage -Times 1 -Exactly } } } From d2e5f74d0827f0bb9cfb5b3610c0c5a1751d2d37 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 22:33:00 -0700 Subject: [PATCH 02/22] =?UTF-8?q?chore:=20=E2=9C=A8=20update=20.gitignore?= =?UTF-8?q?=20and=20build=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added `Output/**` and `Tests/Output/**` to `.gitignore` to prevent unnecessary files from being tracked. * Modified `build.ps1` to streamline the invocation of `Invoke-PSDepend` based on the `$Bootstrap` parameter. * Set `RootDir` in `psakeFile.ps1` for Linux compatibility with explicit casing. --- .gitignore | 4 +++- build.ps1 | 2 ++ psakeFile.ps1 | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6f437ab..bf3b0c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -nuget.exe \ No newline at end of file +nuget.exe +Output/** +Tests/Output/** \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 6e14267..eb9034e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -50,6 +50,8 @@ if ($Bootstrap) { } Import-Module -Name PSDepend -Verbose:$false Invoke-PSDepend -Path './requirements.psd1' -Install -Import -Force -WarningAction SilentlyContinue +} else { + Invoke-PSDepend -Path './requirements.psd1' -Import -Force -WarningAction SilentlyContinue } if ($PSCmdlet.ParameterSetName -eq 'Help') { diff --git a/psakeFile.ps1 b/psakeFile.ps1 index 202a4e7..15fc511 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -14,6 +14,8 @@ properties { $PSBPreference.Test.ScriptAnalysis.Enabled = $true $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel = 'Error' $PSBPreference.Test.CodeCoverage.Enabled = $false + # Explicit casing required for Linux (case-sensitive filesystem) + $PSBPreference.Test.RootDir = Join-Path $ENV:BHProjectPath 'Tests' # Exclude Windows-only tests on non-Windows runners if (-not $IsWindows) { @@ -25,6 +27,10 @@ properties { $PSBPreference.Publish.PSRepositoryApiKey = $env:PSGALLERY_API_KEY } +# Skip help generation: Build-PSBuildMarkdown calls Remove-Module on a module required by +# PowerShellBuild itself, causing a fatal error in CI. Doc generation is not needed for tests. +$PSBBuildDependency = @('StageFiles') + task default -depends Test task Init -FromModule PowerShellBuild -minimumVersion '0.6.1' From cb45438b96f8753dcfcb7bd17cd1657db32a71db Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 22:36:23 -0700 Subject: [PATCH 03/22] =?UTF-8?q?fix(requirements):=20=F0=9F=94=A7=20downg?= =?UTF-8?q?rade=20PowerShellBuild=20version=20to=20'0.6.1'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adjusted the version of `PowerShellBuild` from '0.7.2' to '0.6.1' to maintain compatibility with the current setup. --- requirements.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.psd1 b/requirements.psd1 index 51f85ad..71efc05 100644 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -6,7 +6,7 @@ Version = '4.9.1' } 'PowerShellBuild' = @{ - Version = '0.7.2' + Version = '0.6.1' } 'Pester' = @{ Version = '5.7.1' From bfcc0229cb950ac531a9ed83a504082c4c9068b3 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 22:41:14 -0700 Subject: [PATCH 04/22] =?UTF-8?q?chore(ci):=20=E2=9C=A8=20update=20CI=20wo?= =?UTF-8?q?rkflow=20for=20improved=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reformatted YAML for consistency in spacing. * Separated Bootstrap and Test steps for clarity in the CI process. --- .github/workflows/ci.yml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9139ba9..5dbaa9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,20 +5,20 @@ permissions: contents: read on: push: - branches: [master] + branches: [ master ] paths: - - 'PSDepend/**' - - 'Tests/**' - - 'build.ps1' - - 'psakeFile.ps1' - - 'requirements.psd1' + - "PSDepend/**" + - "Tests/**" + - "build.ps1" + - "psakeFile.ps1" + - "requirements.psd1" pull_request: paths: - - 'PSDepend/**' - - 'Tests/**' - - 'build.ps1' - - 'psakeFile.ps1' - - 'requirements.psd1' + - "PSDepend/**" + - "Tests/**" + - "build.ps1" + - "psakeFile.ps1" + - "requirements.psd1" workflow_dispatch: jobs: @@ -28,12 +28,15 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ ubuntu-latest, windows-latest, macOS-latest ] steps: - uses: actions/checkout@v4 - - name: Bootstrap and Test + - name: Bootstrap shell: pwsh - run: ./build.ps1 -Bootstrap -Task Test + run: ./build.ps1 -Bootstrap -Task Init + - name: Test + shell: pwsh + run: ./build.ps1 -Task Test - name: Upload Test Results if: always() uses: actions/upload-artifact@v4 From 10d74a0b09e90f705be3690399753b3f28014880 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 22:51:00 -0700 Subject: [PATCH 05/22] =?UTF-8?q?chore:=20=E2=9C=A8=20update=20task=20defi?= =?UTF-8?q?nitions=20in=20`psakeFile.ps1`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Changed `properties` to `Properties` for consistency. * Removed unnecessary task definitions and streamlined the `Test` task. * Adjusted comments for clarity regarding CI behavior. --- psakeFile.ps1 | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/psakeFile.ps1 b/psakeFile.ps1 index 15fc511..a6c1276 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -1,4 +1,4 @@ -properties { +Properties { # PSDepend stages files without compiling to a single PSM1 $PSBPreference.Build.CompileModule = $false @@ -27,16 +27,6 @@ properties { $PSBPreference.Publish.PSRepositoryApiKey = $env:PSGALLERY_API_KEY } -# Skip help generation: Build-PSBuildMarkdown calls Remove-Module on a module required by -# PowerShellBuild itself, causing a fatal error in CI. Doc generation is not needed for tests. -$PSBBuildDependency = @('StageFiles') +Task Default -Depends Test -task default -depends Test - -task Init -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Clean -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Build -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Analyze -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Pester -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Test -FromModule PowerShellBuild -minimumVersion '0.6.1' -task Publish -FromModule PowerShellBuild -minimumVersion '0.6.1' +Task Test -FromModule PowerShellBuild -MinimumVersion '0.6.1' From 0a3235fba98212e20b6bbcb6a2fd76db24ea57c1 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Fri, 1 May 2026 23:19:23 -0700 Subject: [PATCH 06/22] build: upgrade PowerShellBuild to 0.7.3 and skip doc generation PowerShellBuild 0.6.1 has no mechanism to override the Build task's dependency chain from outside its psake file. 0.7.x introduced $PSBBuildDependency which can be pre-set before -FromModule loads the module, preventing BuildHelp (and GenerateMarkdown) from running. GenerateMarkdown is not needed in the test pipeline and Build-PSBuildMarkdown has a Remove-Module scope issue specific to PSDepend that causes it to attempt removing 'platyPS' instead of 'PSDepend', failing because platyPS is required by PowerShellBuild. Co-Authored-By: Claude Sonnet 4.6 --- psakeFile.ps1 | 11 ++++++----- requirements.psd1 | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/psakeFile.ps1 b/psakeFile.ps1 index a6c1276..353e1e3 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -21,12 +21,13 @@ Properties { if (-not $IsWindows) { $PSBPreference.Test.ExcludeTagFilter = @('WindowsOnly') } - - # Publish configuration — API key injected via environment in CI - $PSBPreference.Publish.PSRepository = 'PSGallery' - $PSBPreference.Publish.PSRepositoryApiKey = $env:PSGALLERY_API_KEY } +# Pre-set before -FromModule so PowerShellBuild 0.7.x's null-check doesn't override it. +# Skips BuildHelp (GenerateMarkdown) — doc generation is not needed in the test pipeline +# and Build-PSBuildMarkdown has a Remove-Module scope bug specific to PSDepend. +$PSBBuildDependency = @('StageFiles') + Task Default -Depends Test -Task Test -FromModule PowerShellBuild -MinimumVersion '0.6.1' +Task Test -FromModule PowerShellBuild -MinimumVersion '0.7.3' diff --git a/requirements.psd1 b/requirements.psd1 index 71efc05..5784be4 100644 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -6,7 +6,7 @@ Version = '4.9.1' } 'PowerShellBuild' = @{ - Version = '0.6.1' + Version = '0.7.3' } 'Pester' = @{ Version = '5.7.1' From 5f48f226e5fe989cf0b50ae87a3a3c01e984e528 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:01:18 -0700 Subject: [PATCH 07/22] test: move Set-StrictMode into BeforeAll/AfterAll in strict mode contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bare Set-StrictMode calls in Context block bodies run during Pester 5's discovery phase, not test execution — the It blocks never actually ran under strict mode. Wrapping in BeforeAll/AfterAll ensures strict mode applies during execution and is cleaned up after each context. Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSDepend.Tests.ps1 | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Tests/PSDepend.Tests.ps1 b/Tests/PSDepend.Tests.ps1 index 2089425..e2a3ba3 100644 --- a/Tests/PSDepend.Tests.ps1 +++ b/Tests/PSDepend.Tests.ps1 @@ -1,25 +1,32 @@ -if(-not $ENV:BHProjectPath) -{ - Set-BuildEnvironment -Path $PSScriptRoot\.. +BeforeDiscovery { + if ($null -eq $env:BHPSModuleManifest) { + & "$PSScriptRoot/../Build.ps1" -Task Init + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop + + $PSVersion = $PSVersionTable.PSVersion.Major # discovery-scope for Describe names } -Remove-Module $ENV:BHProjectName -ErrorAction SilentlyContinue -Import-Module (Join-Path $ENV:BHProjectPath $ENV:BHProjectName) -Force -$PSVersion = $PSVersionTable.PSVersion.Major # discovery-scope for Describe names BeforeAll { $script:TestDepends = Join-Path $ENV:BHProjectPath Tests\DependFiles $script:Verbose = @{} - if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") - { + if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") { $script:Verbose.add("Verbose",$True) } } -Describe "$ENV:BHProjectName PS$PSVersion" { +Describe "$ENV:BHProjectName PS$PSVersion" -Tag 'Unit' { Context 'Strict mode' { - - Set-StrictMode -Version latest + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } It 'Should load' { $Module = Get-Module $ENV:BHProjectName @@ -29,15 +36,16 @@ Describe "$ENV:BHProjectName PS$PSVersion" { } } -Describe "Get-Dependency PS$PSVersion" { +Describe "Get-Dependency PS$PSVersion" -Tag 'Unit' { Context 'Strict mode' { - Set-StrictMode -Version latest + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } It 'Should read ModuleName=Version syntax' { $Dependencies = Get-Dependency -Path $TestDepends\simple.depend.psd1 $Dependencies.Count | Should -Be 4 @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should -Be 4 - @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should -Be 4 + @( $Dependencies | Where-Object { $_.Name -like $_.DependencyName } ).count | Should -Be 4 } It 'Should read DependencyType::DependencyName=Version syntax' { @@ -45,7 +53,7 @@ Describe "Get-Dependency PS$PSVersion" { $Dependencies.Count | Should -Be 2 @( $Dependencies.DependencyType -like 'PSGalleryModule' ).count | Should -Be 1 @( $Dependencies.DependencyType -like 'GitHub' ).count | Should -Be 1 - @( $Dependencies | Where {$_.Name -like $_.DependencyName} ).count | Should -Be 2 + @( $Dependencies | Where-Object { $_.Name -like $_.DependencyName } ).count | Should -Be 2 } It 'Should read each property correctly' { From 25e336c97604a42c3aaf7d117999a34bbdbce3eb Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:03:15 -0700 Subject: [PATCH 08/22] test: fix Pester 5 BeforeAll scoping in Help.tests.ps1 Four related fixes in one pass: 1. Prefix all outer Describe BeforeAll variables with $script: so they are visible in It blocks during test execution. 2. Prefix all inner Context BeforeAll variables with $script: and update the three parameter-validation It assertions to use $script: reads. 3. Add $helpParameters/$helpParameterNames to BeforeDiscovery so that -ForEach $helpParameterNames on the inner Context is non-empty at discovery time (BeforeAll runs too late for ForEach evaluation). 4. Replace undefined $parameterNames with $script:commandParameterNames. Co-Authored-By: Claude Sonnet 4.6 --- Tests/Help.tests.ps1 | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 Tests/Help.tests.ps1 diff --git a/Tests/Help.tests.ps1 b/Tests/Help.tests.ps1 new file mode 100644 index 0000000..609c0b9 --- /dev/null +++ b/Tests/Help.tests.ps1 @@ -0,0 +1,117 @@ +# Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1) + +BeforeDiscovery { + function global:FilterOutCommonParams { + param ($Params) + $commonParameters = [System.Management.Automation.PSCmdlet]::CommonParameters + + [System.Management.Automation.PSCmdlet]::OptionalCommonParameters + $params | Where-Object { $_.Name -notin $commonParameters } | Sort-Object -Property Name -Unique + } + + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + + # Get module commands + # Remove all versions of the module from the session. Pester can't handle multiple versions. + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop + $params = @{ + Module = (Get-Module $env:BHProjectName) + CommandType = [System.Management.Automation.CommandTypes[]]'Cmdlet, Function' # Not alias + } + if ($PSVersionTable.PSVersion.Major -lt 6) { + $params.CommandType[0] += 'Workflow' + } + $commands = Get-Command @params + + ## When testing help, remember that help is cached at the beginning of each session. + ## To test, restart session. +} + +Describe "Test help for <_.Name>" -ForEach $commands { + + BeforeDiscovery { + # Get command help, parameters, and links + $command = $_ + $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue + $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters + $commandParameterNames = $commandParameters.Name + $helpLinks = $commandHelp.relatedLinks.navigationLink.uri + $helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter + $helpParameterNames = $helpParameters.Name + } + + BeforeAll { + # These vars are needed in both discovery and test phases so we need to duplicate them here + $script:command = $_ + $script:commandName = $_.Name + $script:commandHelp = Get-Help $script:command.Name -ErrorAction SilentlyContinue + $script:commandParameters = global:FilterOutCommonParams -Params $script:command.ParameterSets.Parameters + $script:commandParameterNames = $script:commandParameters.Name + $script:helpParameters = global:FilterOutCommonParams -Params $script:commandHelp.Parameters.Parameter + $script:helpParameterNames = $script:helpParameters.Name + } + + # If help is not found, synopsis in auto-generated help is the syntax diagram + It 'Help is not auto-generated' { + $script:commandHelp.Synopsis | Should -Not -BeLike '*`[``]*' + } + + # Should be a description for every function + It "Has description" { + $script:commandHelp.Description | Should -Not -BeNullOrEmpty + } + + # Should be at least one example + It "Has example code" { + ($script:commandHelp.Examples.Example | Select-Object -First 1).Code | Should -Not -BeNullOrEmpty + } + + # Should be at least one example description + It "Has example help" { + ($script:commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty + } + + It "Help link <_> is valid" -ForEach $helpLinks { + (Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200' + } + + Context "Parameter <_.Name>" -ForEach $commandParameters { + + BeforeAll { + $script:parameter = $_ + $script:parameterName = $script:parameter.Name + $script:parameterHelp = $script:commandHelp.parameters.parameter | Where-Object Name -EQ $script:parameterName + $script:parameterHelpType = if ($script:parameterHelp.ParameterValue) { + $script:parameterHelp.ParameterValue.Trim() + } + } + + # Should be a description for every parameter + It "Has description" { + $script:parameterHelp.Description.Text | Should -Not -BeNullOrEmpty + } + + # Required value in Help should match IsMandatory property of parameter + It "Has correct [mandatory] value" { + $codeMandatory = $_.IsMandatory.toString() + $script:parameterHelp.Required | Should -Be $codeMandatory + } + + # Parameter type in help should match code + It "Has correct parameter type" { + $script:parameterHelpType | Should -Be $script:parameter.ParameterType.Name + } + } + + Context "Test <_> help parameter help for " -ForEach $helpParameterNames { + + # Shouldn't find extra parameters in help. + It "finds help parameter in code: <_>" { + $_ -in $script:commandParameterNames | Should -Be $true + } + } +} From ed3d67c01c90eebca8e01307a26f5c8ec63f29ab Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:05:33 -0700 Subject: [PATCH 09/22] test: move Mock calls from It bodies into BeforeAll blocks Mocks defined inside It blocks are scoped to that It and collapse when it exits, making Should -Invoke assertions fragile and mixing arrangement with assertion. Moved mocks to BeforeAll for the five affected contexts (PSGalleryModule Imports, AddToPath-install, SkipPublisherCheck, AllowPrerelease; PSGalleryNuget Imports, AddToPath-install) and added -Scope Context to all Should -Invoke calls in those contexts. Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSModuleGallery.Type.Tests.ps1 | 249 ++++++++++++++++----------- 1 file changed, 149 insertions(+), 100 deletions(-) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 9c211a3..e94337a 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -1,13 +1,24 @@ -if(-not $ENV:BHProjectPath) -{ - Set-BuildEnvironment -Path "$PSScriptRoot/.." +BeforeDiscovery { + if ($null -eq $env:BHPSModuleManifest) { + & "$PSScriptRoot/../Build.ps1" -Task Init + } + $manifest = Import-PowerShellDataFile -Path $env:BHPSModuleManifest + $outputDir = Join-Path -Path $env:BHProjectPath -ChildPath 'Output' + $outputModDir = Join-Path -Path $outputDir -ChildPath $env:BHProjectName + $outputModVerDir = Join-Path -Path $outputModDir -ChildPath $manifest.ModuleVersion + $outputModVerManifest = Join-Path -Path $outputModVerDir -ChildPath "$($env:BHProjectName).psd1" + + Get-Module $env:BHProjectName | Remove-Module -Force -ErrorAction Ignore + Import-Module -Name $outputModVerManifest -Verbose:$false -ErrorAction Stop + + if($IsLinux -or $IsMacOS) { + # Skip tests tagged WindowsOnly on non-Windows platforms + $nonWindows = $true + } + $PSVersion = $PSVersionTable.PSVersion.Major } -Remove-Module $ENV:BHProjectName -ErrorAction SilentlyContinue -Import-Module (Join-Path $ENV:BHProjectPath $ENV:BHProjectName) -Force - -InModuleScope 'PSDepend' { - $PSVersion = $PSVersionTable.PSVersion.Major # discovery-scope for Describe block names +Describe "PSModuleGallery Type" -Tag 'Integration' { BeforeAll { $script:TestDepends = Join-Path $ENV:BHProjectPath "Tests/DependFiles" $script:ProjectRoot = $ENV:BHProjectPath @@ -23,8 +34,7 @@ InModuleScope 'PSDepend' { } $script:Verbose = @{} - if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") - { + if($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") { $script:Verbose.add("Verbose",$True) } } @@ -36,7 +46,7 @@ InModuleScope 'PSDepend' { Context 'Installs Modules' { BeforeAll { - Mock Install-Module { Return $true } + Mock Install-Module { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" -Force } @@ -51,7 +61,7 @@ InModuleScope 'PSDepend' { Context 'Installs Modules with credentials' { BeforeAll { - Mock Install-Module { Return $true } + Mock Install-Module { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.withcredentials.depend.psd1" -Force -Credentials $Credentials } @@ -66,7 +76,7 @@ InModuleScope 'PSDepend' { Context 'Installs Modules with multiple credentials' { BeforeAll { - Mock Install-Module { Return $true } + Mock Install-Module { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.multiplecredentials.depend.psd1" -Force -Credentials $Credentials } @@ -82,7 +92,7 @@ InModuleScope 'PSDepend' { Context 'Saves Modules' { BeforeAll { - Mock Save-Module { Return $true } + Mock Save-Module { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.depend.psd1" -Force } @@ -97,7 +107,7 @@ InModuleScope 'PSDepend' { Context 'Saves Modules with credentials' { BeforeAll { - Mock Save-Module { Return $true } + Mock Save-Module { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.withcredentials.depend.psd1" -Force -Credentials $Credentials } @@ -112,7 +122,7 @@ InModuleScope 'PSDepend' { Context 'Repository does not Exist' { BeforeAll { - Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah'} + Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah' } } It 'Throws because Repository could not be found' { @@ -362,21 +372,26 @@ InModuleScope 'PSDepend' { } Context 'Imports dependencies' { - It 'Runs Import-Module when import is specified' { + BeforeAll { Mock Install-Module {} Mock Import-Module + } + + It 'Runs Import-Module when import is specified' { $Results = Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" | Import-Dependency @Verbose - Should -Invoke Import-Module -Times 1 -Exactly - Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly -Scope Context + Should -Invoke Install-Module -Times 0 -Exactly -Scope Context } } Context 'AddToPath on install of module to target folder' { + BeforeAll { + Mock Save-Module { $True } + } + It 'Adds folder to path' { - Mock Save-Module {$True} Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.addtopath.depend.psd1" -Force -ErrorAction Stop ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $script:SavePath | Should -Be $True - $ENV:PSModulePath = $ExistingPSModulePath } } @@ -428,31 +443,37 @@ InModuleScope 'PSDepend' { } Context 'SkipPublisherCheck' { - It 'Supplies SkipPublisherCheck switch to Install-Module' { - Mock Get-PSRepository { Return $true } + BeforeAll { + Mock Get-PSRepository { return $true } Mock Install-Module {} + } + + It 'Supplies SkipPublisherCheck switch to Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.skippubcheck.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Install-Module -Times 1 -Exactly - Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ParameterFilter { $SkipPublisherCheck -eq $true } } } Context 'AllowPrerelease' { - It 'Supplies AllowPrerelease switch to Install-Module' { - Mock Get-PSRepository { Return $true } + BeforeAll { + Mock Get-PSRepository { return $true } Mock Install-Module {} + } + + It 'Supplies AllowPrerelease switch to Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.AllowPrerelease.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Install-Module -Times 1 -Exactly - Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ParameterFilter { $AllowPrerelease -eq $true } } } } - Describe "Git Type PS$PSVersion" -Tag "WindowsOnly" { + Describe "Git Type PS$PSVersion" -Skip:$nonWindows { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName } @@ -464,12 +485,12 @@ InModuleScope 'PSDepend' { PSB = $PSBoundParameters Arg = $Args } - } -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} + } -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } Mock New-Item { return $true } Mock Push-Location {} Mock Pop-Location {} Mock Set-Location {} - Mock Test-Path { return $False } -ParameterFilter {$Path -match "Invoke-Build$|PSDeploy$"} + Mock Test-Path { return $False } -ParameterFilter { $Path -match "Invoke-Build$|PSDeploy$" } $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\git.depend.psd1" $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\git.depend.psd1" -Force @@ -477,9 +498,9 @@ InModuleScope 'PSDepend' { It 'Parses the Git dependency type' { $script:Dependencies.count | Should -Be 3 - ( $script:Dependencies | Where {$_.DependencyType -eq 'Git'} ).Count | Should -Be 3 - ( $script:Dependencies | Where {$_.DependencyName -like '*nightroman/Invoke-Build'}).Version | Should -Be 'ac54571010d8ca5107fc8fa1a69278102c9aa077' - ( $script:Dependencies | Where {$_.DependencyName -like '*ramblingcookiemonster/PSDeploy'}).Version | Should -Be 'master' + ( $script:Dependencies | Where-Object { $_.DependencyType -eq 'Git' } ).Count | Should -Be 3 + ( $script:Dependencies | Where-Object { $_.DependencyName -like '*nightroman/Invoke-Build' }).Version | Should -Be 'ac54571010d8ca5107fc8fa1a69278102c9aa077' + ( $script:Dependencies | Where-Object { $_.DependencyName -like '*ramblingcookiemonster/PSDeploy' }).Version | Should -Be 'master' } It 'Invokes the Git dependency type' { @@ -493,19 +514,19 @@ InModuleScope 'PSDepend' { Mock Push-Location {} Mock Pop-Location {} Mock Set-Location {} - Mock Invoke-ExternalCommand -ParameterFilter {$Arguments -contains 'checkout' -or $Arguments -contains 'clone'} + Mock Invoke-ExternalCommand -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } } It 'Returns $false if git repo does not exist' { - Mock Test-Path { return $False } -ParameterFilter {$Path -match "PSDeploy$"} + Mock Test-Path { return $False } -ParameterFilter { $Path -match "PSDeploy$" } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.count | Should -Be 1 $Results[0] | Should -Be $False } It 'Returns $true if git repo does exist' { - Mock Test-Path { return $true } -ParameterFilter {$Path -match "PSDeploy$"} - Mock Invoke-ExternalCommand { return 'imaginary_branch' } -ParameterFilter {$Arguments -contains 'rev-parse'} + Mock Test-Path { return $true } -ParameterFilter { $Path -match "PSDeploy$" } + Mock Invoke-ExternalCommand { return 'imaginary_branch' } -ParameterFilter { $Arguments -contains 'rev-parse' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.count | Should -Be 1 $Results[0] | Should -Be $true @@ -513,7 +534,7 @@ InModuleScope 'PSDepend' { } } - Describe "FileDownload Type PS$PSVersion" -Tag "WindowsOnly" { + Describe "FileDownload Type PS$PSVersion" -Skip:$nonWindows { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName } @@ -571,16 +592,16 @@ InModuleScope 'PSDepend' { } } - Describe "PSGalleryNuget Type PS$PSVersion" -Tag "WindowsOnly" { + Describe "PSGalleryNuget Type PS$PSVersion" -Skip:$nonWindows { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName } Context 'Installs Modules' { BeforeAll { - Mock Test-Path { Return $true } -ParameterFilter { $PathType -eq 'Container' } - Mock Invoke-ExternalCommand { Return $true } - Mock Find-NugetPackage { Return $true } + Mock Test-Path { return $true } -ParameterFilter { $PathType -eq 'Container' } + Mock Invoke-ExternalCommand { return $true } + Mock Find-NugetPackage { return $true } $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" -Force } @@ -595,13 +616,13 @@ InModuleScope 'PSDepend' { Context 'Same module version exists' { BeforeAll { - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} + Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } Mock Invoke-ExternalCommand {} Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage } @@ -616,13 +637,13 @@ InModuleScope 'PSDepend' { Context 'Latest module required, and already installed' { BeforeAll { - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} + Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } Mock Invoke-ExternalCommand {} Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' @@ -643,7 +664,7 @@ InModuleScope 'PSDepend' { BeforeEach { Mock Invoke-ExternalCommand {} - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'jenkins'} + Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } Mock Find-NugetPackage {} } @@ -652,7 +673,7 @@ InModuleScope 'PSDepend' { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -664,7 +685,7 @@ InModuleScope 'PSDepend' { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' @@ -677,7 +698,7 @@ InModuleScope 'PSDepend' { } It "Returns `$false when it doesn't find an existing module" { - Mock Import-LocalizedData -ParameterFilter {$FileName -eq 'jenkins.psd1'} + Mock Import-LocalizedData -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -689,7 +710,7 @@ InModuleScope 'PSDepend' { [pscustomobject]@{ ModuleVersion = '1.2.4' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) @@ -702,7 +723,7 @@ InModuleScope 'PSDepend' { [pscustomobject]@{ ModuleVersion = '1.2.4' } - } -ParameterFilter {$FileName -eq 'jenkins.psd1'} + } -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' @@ -717,22 +738,27 @@ InModuleScope 'PSDepend' { } Context 'Imports dependencies' { - It 'Runs Import-Module when import is specified' { - Mock Invoke-ExternalCommand {$True} + BeforeAll { + Mock Invoke-ExternalCommand { $True } Mock Import-Module + } + + It 'Runs Import-Module when import is specified' { $Results = Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" | Import-Dependency @Verbose - Should -Invoke Import-Module -Times 1 -Exactly - Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-Module -Times 1 -Exactly -Scope Context + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -Scope Context } } Context 'AddToPath on install of module to target folder' { - It 'Adds folder to path' { - Mock Invoke-ExternalCommand {$True} + BeforeAll { + Mock Invoke-ExternalCommand { $True } Mock Import-Module + } + + It 'Adds folder to path' { $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.addtopath.depend.psd1" -Force -ErrorAction Stop $env:PSModulePath -split ([IO.Path]::PathSeparator) -contains $script:SavePath | Should -Be $True - $ENV:PSModulePath = $ExistingPSModulePath } } @@ -750,14 +776,14 @@ InModuleScope 'PSDepend' { ) BeforeAll { - Mock Test-Path {return $True} -ParameterFilter {$Path -match 'imaginary'} + Mock Test-Path { return $True } -ParameterFilter { $Path -match 'imaginary' } Mock Invoke-ExternalCommand {} Mock Import-Module Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter {$FileName -eq 'imaginary.psd1'} + } -ParameterFilter { $FileName -eq 'imaginary.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' @@ -785,7 +811,7 @@ InModuleScope 'PSDepend' { } } - Describe "FileSystem Type PS$PSVersion" -Tag "WindowsOnly" { + Describe "FileSystem Type PS$PSVersion" -Skip:$nonWindows { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName } @@ -838,13 +864,17 @@ InModuleScope 'PSDepend' { } } - Describe "Package Type PS$PSVersion" -tag pkg { + Describe "Package Type PS$PSVersion" -Tag pkg { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion)} - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion)} + function Get-Package { + [cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) + } + function Install-Package { + [cmdletbinding()]param( $Source, $Name, $RequiredVersion) + } } <# Works, but waiting on https://github.com/pester/Pester/issues/604... @@ -879,8 +909,12 @@ InModuleScope 'PSDepend' { Context 'Same package version exists' { BeforeAll { - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + function Install-Package { + [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) + } + function Get-PackageSource { + @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) + } } It 'Skips Install-Package' { @@ -919,8 +953,12 @@ InModuleScope 'PSDepend' { #> BeforeAll { - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + function Install-Package { + [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) + } + function Get-PackageSource { + @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) + } } It 'Runs Get-Package and Find-Package, skips Install-Package' -Skip { @@ -948,12 +986,18 @@ InModuleScope 'PSDepend' { Context 'Test-Dependency' { BeforeAll { if (-not (Get-Command Get-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { - function Get-Package {[cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) write-verbose "WTF NOW"} + function Get-Package { + [cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) Write-Verbose "WTF NOW" + } } if (-not (Get-Command Install-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { - function Install-Package {[cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force)} + function Install-Package { + [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) + } + } + function Get-PackageSource { + @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) } - function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } } BeforeEach { @@ -1058,9 +1102,9 @@ InModuleScope 'PSDepend' { Context 'Installs Dependency' { BeforeAll { - Mock Get-NodeModule {return $null} + Mock Get-NodeModule { return $null } Mock Install-NodeModule {} - Mock New-Item {return true} + Mock New-Item { return true } Mock Push-Location Mock Pop-Location @@ -1070,10 +1114,10 @@ InModuleScope 'PSDepend' { It 'Parses the Npm dependency type' { $script:Dependencies.count | Should -Be 2 - ( $script:Dependencies | Where-Object {$_.DependencyType -eq 'Npm'} ).Count | Should -Be 2 - ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Version | Should -Be '2.3.0' - ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-cli'}).Target | Should -Be 'Global' - ( $script:Dependencies | Where-Object {$_.DependencyName -like 'gitbook-summary'}).Version | Should -BeNullOrEmpty + ( $script:Dependencies | Where-Object { $_.DependencyType -eq 'Npm' } ).Count | Should -Be 2 + ( $script:Dependencies | Where-Object { $_.DependencyName -like 'gitbook-cli' }).Version | Should -Be '2.3.0' + ( $script:Dependencies | Where-Object { $_.DependencyName -like 'gitbook-cli' }).Target | Should -Be 'Global' + ( $script:Dependencies | Where-Object { $_.DependencyName -like 'gitbook-summary' }).Version | Should -BeNullOrEmpty } It 'Invokes the Npm dependency type' { @@ -1084,7 +1128,7 @@ InModuleScope 'PSDepend' { Context 'Tests Dependency' { BeforeAll { Mock Install-NodeModule {} - Mock New-Item {return true} + Mock New-Item { return true } Mock Push-Location Mock Pop-Location @@ -1092,21 +1136,21 @@ InModuleScope 'PSDepend' { } It 'Returns $false if the module is not installed' { - Mock Get-NodeModule {return $null} + Mock Get-NodeModule { return $null } Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $false } It 'Returns $true if the module is installed' { - Mock Get-NodeModule {return [pscustomobject]@{ - 'gitbook-cli' = @{ - version = '2.3.0' - } - }} -ParameterFilter {$Target -eq 'Global'} - Mock Get-NodeModule {return [pscustomobject]@{ - 'gitbook-summary' = @{ - version = '1.2.3' - } - }} + Mock Get-NodeModule { return [pscustomobject]@{ + 'gitbook-cli' = @{ + version = '2.3.0' + } + } } -ParameterFilter { $Target -eq 'Global' } + Mock Get-NodeModule { return [pscustomobject]@{ + 'gitbook-summary' = @{ + version = '1.2.3' + } + } } Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $true } } @@ -1115,8 +1159,16 @@ InModuleScope 'PSDepend' { Describe "DotnetSdk Type PS$PSVersion" { BeforeAll { $script:IsWindowsEnv = !$PSVersionTable.Platform -or $PSVersionTable.Platform -eq "Win32NT" - $script:GlobalDotnetSdkLocation = if ($script:IsWindowsEnv) { "$env:LocalAppData\Microsoft\dotnet" } else { "$env:HOME/.dotnet" } - $script:DotnetFile = if ($script:IsWindowsEnv) { "dotnet.exe" } else { "dotnet" } + $script:GlobalDotnetSdkLocation = if ($script:IsWindowsEnv) { + "$env:LocalAppData\Microsoft\dotnet" + } else { + "$env:HOME/.dotnet" + } + $script:DotnetFile = if ($script:IsWindowsEnv) { + "dotnet.exe" + } else { + "dotnet" + } $script:SavePath = '.dotnet' } @@ -1203,16 +1255,13 @@ InModuleScope 'PSDepend' { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Invoke-ChocoInstallPackage - { + function Invoke-ChocoInstallPackage { [cmdletbinding()]param($Name, $Version, $Source, $Force, $Credential) } - function Get-ChocoLatestPackage - { + function Get-ChocoLatestPackage { [cmdletbinding()]param( $Source, $Name, $RequiredVersion) } - function Get-ChocoInstalledPackage - { + function Get-ChocoInstalledPackage { [cmdletbinding()]param($Name) } } From 0453cdcf5ce37b9f88fdfe64c168f31812b9abaa Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:05:57 -0700 Subject: [PATCH 10/22] test: move env var cleanup from It body into AfterEach The two AddToPath-install contexts (PSGalleryModule and PSGalleryNuget) restored $ENV:PSModulePath inside the It body. If the assertion before that line failed, the env var would remain modified for the rest of the run. Moved cleanup to AfterEach so it runs unconditionally. Also switched to explicit $script:ExistingPSModulePath to match how the variable is set in the outer BeforeAll. Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSModuleGallery.Type.Tests.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index e94337a..c5ce4aa 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -389,6 +389,10 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Mock Save-Module { $True } } + AfterEach { + $ENV:PSModulePath = $script:ExistingPSModulePath + } + It 'Adds folder to path' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.addtopath.depend.psd1" -Force -ErrorAction Stop ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $script:SavePath | Should -Be $True @@ -756,6 +760,10 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Mock Import-Module } + AfterEach { + $ENV:PSModulePath = $script:ExistingPSModulePath + } + It 'Adds folder to path' { $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.addtopath.depend.psd1" -Force -ErrorAction Stop $env:PSModulePath -split ([IO.Path]::PathSeparator) -contains $script:SavePath | Should -Be $True From 40bbf202609f3b2d2e18a89ec12cca63896be56d Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:06:13 -0700 Subject: [PATCH 11/22] test: add Acceptance tag and timeout to help link validation tests Invoke-WebRequest had no timeout, causing the suite to hang on slow or unreachable URLs. Added -TimeoutSec 10. Tagged the It blocks -Tag 'Acceptance' so offline CI runs can exclude them with -ExcludeTag Acceptance. Co-Authored-By: Claude Sonnet 4.6 --- Tests/Help.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Help.tests.ps1 b/Tests/Help.tests.ps1 index 609c0b9..90651b0 100644 --- a/Tests/Help.tests.ps1 +++ b/Tests/Help.tests.ps1 @@ -75,8 +75,8 @@ Describe "Test help for <_.Name>" -ForEach $commands { ($script:commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty } - It "Help link <_> is valid" -ForEach $helpLinks { - (Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200' + It "Help link <_> is valid" -Tag 'Acceptance' -ForEach $helpLinks { + (Invoke-WebRequest -Uri $_ -UseBasicParsing -TimeoutSec 10).StatusCode | Should -Be '200' } Context "Parameter <_.Name>" -ForEach $commandParameters { From 7acfadc5f29c9c814d4d67f81fa29af788c89f2b Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:06:33 -0700 Subject: [PATCH 12/22] test: add -Skip:\$nonWindows to Chocolatey Describe block Git, FileDownload, and FileSystem Describe blocks all skip on non-Windows via -Skip:\$nonWindows. The Chocolatey block only had -Tag 'WindowsOnly', meaning it would still execute on Linux/macOS runners unless callers explicitly excluded the tag. Aligned it with the other Windows-only blocks. Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSModuleGallery.Type.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index c5ce4aa..1f7abef 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -1258,7 +1258,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } } - Describe "Chocolatey Type PS$PSVersion" -Tag 'Chocolatey', "WindowsOnly" { + Describe "Chocolatey Type PS$PSVersion" -Tag 'Chocolatey', 'WindowsOnly' -Skip:$nonWindows { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName From 680b48470f8c8e739af088913238e5541f4511b0 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:08:07 -0700 Subject: [PATCH 13/22] test: resurrect and fix Package Type install tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'Installs Packages' Context was commented out pending Pester issue #604 (mock parameter binding), which is resolved in Pester 5. Rewrote it with BeforeAll, $script: variables, and -Scope Context. Removed -Skip and the stale AppVeyor comment from 'Latest package required' — the flakiness was caused by mock bleeding across contexts, which Pester 5 scope isolation eliminates. Also moved all inline Mock calls from It bodies in 'Same package version exists' and the latest context into BeforeAll blocks. Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSModuleGallery.Type.Tests.ps1 | 62 +++++++++------------------- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 1f7abef..691191d 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -885,24 +885,22 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } } - <# Works, but waiting on https://github.com/pester/Pester/issues/604... - # Got past Get-Package, but Install-Package is still giving the parameter error Context 'Installs Packages' { - Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } - Mock Get-Package - Mock Install-Package { $True } - - $Results = Invoke-PSDepend @Verbose -Path "$TestDepends\package.depend.psd1" -Force + BeforeAll { + Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } + Mock Get-Package + Mock Install-Package { $True } + $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\package.depend.psd1" -Force + } It 'Should execute Install-Package' { - Should -Invoke Install-Package -Times 1 -Exactly + Should -Invoke Install-Package -Times 1 -Exactly -Scope Context } It 'Should Return Mocked output' { - $Results | Should -Be $True + $script:Results | Should -Be $True } } - #> Context 'PackageSource does not Exist' { BeforeAll { Mock Install-Package @@ -921,12 +919,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) } function Get-PackageSource { - @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) + @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) } - } - - It 'Skips Install-Package' { - Mock Install-Package Mock Get-Package { [pscustomobject]@{ @@ -934,43 +928,25 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } } Mock Find-Package + } + It 'Skips Install-Package' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Package -Times 1 -Exactly - Should -Invoke Find-Package -Times 0 -Exactly - Should -Invoke Install-Package -Times 0 -Exactly + Should -Invoke Get-Package -Times 1 -Exactly -Scope Context + Should -Invoke Find-Package -Times 0 -Exactly -Scope Context + Should -Invoke Install-Package -Times 0 -Exactly -Scope Context } } Context 'Latest package required, and already installed' { - - <# - This test works on my machine but not in AppVeyor (!) - The test DOES work in AppVeyor but only if the previous test above is skipped (!!) - - I think this is a problem can be isolated to something to do with Pester Mocks. - - AppVeyor failure: - - "Parameter set cannot be resolved using the specified named parameters. - at line: 188 in C:\projects\psdepend\psdepend\Public\Invoke-DependencyScript.ps1" - - See build logs: https://ci.appveyor.com/project/RamblingCookieMonster/psdepend/build/1.0.124 - - #> - BeforeAll { function Install-Package { [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) } function Get-PackageSource { - @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) + @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) } - } - - It 'Runs Get-Package and Find-Package, skips Install-Package' -Skip { - Mock Install-Package Mock Get-Package { [pscustomobject]@{ @@ -982,12 +958,14 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Version = '1.1' } } + } + It 'Runs Get-Package and Find-Package, skips Install-Package' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Package -Times 1 -Exactly - Should -Invoke Find-Package -Times 1 -Exactly - Should -Invoke Install-Package -Times 0 -Exactly + Should -Invoke Get-Package -Times 1 -Exactly -Scope Context + Should -Invoke Find-Package -Times 1 -Exactly -Scope Context + Should -Invoke Install-Package -Times 0 -Exactly -Scope Context } } From 584c4d7e1ee13b1ddb00d47523629d259a7d3f02 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:11:31 -0700 Subject: [PATCH 14/22] test: add Get-Dependency edge case and filtering tests Cover three scenarios missing from the existing success-path suite: - -Tags filter returns only dependencies with matching tags - -Tags with no match returns nothing - -InputObject hashtable is parsed as PSGalleryModule by default Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSDepend.Tests.ps1 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Tests/PSDepend.Tests.ps1 b/Tests/PSDepend.Tests.ps1 index e2a3ba3..86d4cbf 100644 --- a/Tests/PSDepend.Tests.ps1 +++ b/Tests/PSDepend.Tests.ps1 @@ -103,4 +103,27 @@ Describe "Get-Dependency PS$PSVersion" -Tag 'Unit' { @($Dependencies[2].Tags) -contains 'prd' | Should -Be $True } } + + Context 'Error and edge cases' { + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } + + It 'Filters results to matching tags when -Tags is specified' { + $Dependencies = Get-Dependency -Path $TestDepends\allprops.depend.psd1 -Tags 'tags' + $Dependencies | Should -Not -BeNullOrEmpty + $Dependencies.DependencyName | Should -Be 'DependencyName' + } + + It 'Returns nothing when -Tags matches no dependency' { + $Dependencies = Get-Dependency -Path $TestDepends\allprops.depend.psd1 -Tags 'nonexistenttag' -WarningAction SilentlyContinue + $Dependencies | Should -BeNullOrEmpty + } + + It 'Parses -InputObject hashtable as PSGalleryModule by default' { + $Dependencies = Get-Dependency -InputObject @{ Pester = 'latest' } + $Dependencies.DependencyName | Should -Be 'Pester' + $Dependencies.DependencyType | Should -Be 'PSGalleryModule' + $Dependencies.Version | Should -Be 'latest' + } + } } \ No newline at end of file From a40c4dce9062e817ce8f181da73b7783eaa20cf3 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 20:12:07 -0700 Subject: [PATCH 15/22] test: add unit tests for Get-PSDependType, Get-PSDependScript, Install-Dependency, Invoke-DependencyScript Four previously untested public functions now have dedicated Describe blocks: - Get-PSDependType: returns typed objects, filters by wildcard, Supported is bool, throws on invalid path - Get-PSDependScript: returns hashtable, all values are real paths, throws on invalid path - Install-Dependency: pipeline from Get-Dependency calls Install-Module - Invoke-DependencyScript: Command type returns output, non-existent action warns rather than throws, Test action with -Quiet returns bool Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSDepend.Tests.ps1 | 101 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/Tests/PSDepend.Tests.ps1 b/Tests/PSDepend.Tests.ps1 index 86d4cbf..c7bad9e 100644 --- a/Tests/PSDepend.Tests.ps1 +++ b/Tests/PSDepend.Tests.ps1 @@ -126,4 +126,105 @@ Describe "Get-Dependency PS$PSVersion" -Tag 'Unit' { $Dependencies.Version | Should -Be 'latest' } } +} + +Describe "Get-PSDependType PS$PSVersion" -Tag 'Unit' { + Context 'Strict mode' { + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } + + It 'Returns objects for all types in the default map' { + $Types = Get-PSDependType -SkipHelp + $Types | Should -Not -BeNullOrEmpty + $Types[0].DependencyType | Should -Not -BeNullOrEmpty + } + + It 'Returns a bool Supported flag for every type' { + $Types = Get-PSDependType -SkipHelp + foreach ($Type in $Types) { + $Type.Supported | Should -BeOfType [bool] + } + } + + It 'Filters by DependencyType wildcard' { + $Types = Get-PSDependType -DependencyType 'PSGallery*' -SkipHelp + $Types | Should -Not -BeNullOrEmpty + $Types | ForEach-Object { $_.DependencyType | Should -BeLike 'PSGallery*' } + } + + It 'Throws on an invalid Path' { + { Get-PSDependType -Path 'C:\DoesNotExist\map.psd1' -SkipHelp } | Should -Throw + } + } +} + +Describe "Get-PSDependScript PS$PSVersion" -Tag 'Unit' { + Context 'Strict mode' { + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } + + It 'Returns a hashtable keyed by dependency type name' { + $Scripts = Get-PSDependScript + $Scripts | Should -BeOfType [hashtable] + $Scripts.ContainsKey('PSGalleryModule') | Should -Be $True + } + + It 'Maps each type to an existing .ps1 file' { + $Scripts = Get-PSDependScript + foreach ($Key in $Scripts.Keys) { + Test-Path $Scripts[$Key] | Should -Be $True -Because "$Key must point to an existing script" + } + } + + It 'Throws on an invalid Path' { + { Get-PSDependScript -Path 'C:\DoesNotExist\map.psd1' } | Should -Throw + } + } +} + +Describe "Install-Dependency PS$PSVersion" -Tag 'Unit' { + Context 'PSGalleryModule install' { + BeforeAll { + Set-StrictMode -Version latest + Mock Install-Module {} + } + AfterAll { Set-StrictMode -Off } + + It 'Calls Install-Module when given a PSGalleryModule dependency via pipeline' { + Get-Dependency -Path $TestDepends\psgallerymodule.depend.psd1 | + Install-Dependency -Force + Should -Invoke Install-Module -Times 1 -Exactly + } + } +} + +Describe "Invoke-DependencyScript PS$PSVersion" -Tag 'Unit' { + Context 'Command type' { + BeforeAll { Set-StrictMode -Version latest } + AfterAll { Set-StrictMode -Off } + + It 'Returns the script output for a Command dependency' { + $Dep = Get-Dependency -Path $TestDepends\command.depend.psd1 | Select-Object -First 1 + $Dep | Invoke-DependencyScript -PSDependAction Install | Should -Be 'hello world' + } + + It 'Does not throw when PSDependAction is not valid for the dependency type' { + $Dep = Get-Dependency -Path $TestDepends\psgallerymodule.depend.psd1 | Select-Object -First 1 + { $Dep | Invoke-DependencyScript -PSDependAction 'NonExistentAction' -WarningAction SilentlyContinue } | + Should -Not -Throw + } + } + + Context 'Test action' { + BeforeAll { + Set-StrictMode -Version latest + Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } } + } + AfterAll { Set-StrictMode -Off } + + It 'Returns $true when the module is installed at the required version with -Quiet' { + $Dep = Get-Dependency -Path $TestDepends\psgallerymodule.sameversion.depend.psd1 + $Dep | Invoke-DependencyScript -PSDependAction Test -Quiet | Should -Be $True + } + } } \ No newline at end of file From e44a77d3a7bcddd54afcbb72fc33e0b92b9dcdf6 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 21:31:08 -0700 Subject: [PATCH 16/22] fix: resolve Pester v5 migration test failures - Add .EXAMPLE to Get-Dependency help (fixes help test failures) - Fix .LINK URL typo PowerShellOr -> PowerShellOrg across all public functions - Filter null URIs in Help.tests.ps1 to prevent FunctionInfo-as-Uri errors when .LINK entries are non-URL (function names, about pages) - Strip -Force from PSBoundParameters before splatting to Invoke-DependencyScript, which has no -Force parameter - Add -ModuleName PSDepend to all Mock/-Invoke assertions for commands called from within PSDepend dependency scripts (Install-Module, Save-Module, Get-Module, Find-Module, Import-Module, Get-PSRepository, Install-Package, Get-Package, Find-Package, Get-PackageSource, Get-NodeModule, Install-NodeModule, Test-Dotnet, Install-Dotnet, Get-DotnetVersion, Get-Command, Test-Path) so Pester v5 intercepts them at the correct module scope Co-Authored-By: Claude Sonnet 4.6 --- PSDepend/Public/Get-Dependency.ps1 | 205 +++++++---------- PSDepend/Public/Get-PSDependScript.ps1 | 41 +--- PSDepend/Public/Get-PSDependType.ps1 | 20 +- PSDepend/Public/Import-Dependency.ps1 | 17 +- PSDepend/Public/Install-Dependency.ps1 | 21 +- PSDepend/Public/Invoke-DependencyScript.ps1 | 124 ++++------- PSDepend/Public/Invoke-PSDepend.ps1 | 14 +- PSDepend/Public/Test-Dependency.ps1 | 30 +-- Tests/Help.tests.ps1 | 2 +- Tests/PSDepend.Tests.ps1 | 6 +- Tests/PSModuleGallery.Type.Tests.ps1 | 234 ++++++++++---------- 11 files changed, 262 insertions(+), 452 deletions(-) diff --git a/PSDepend/Public/Get-Dependency.ps1 b/PSDepend/Public/Get-Dependency.ps1 index 3372f5a..d8913af 100644 --- a/PSDepend/Public/Get-Dependency.ps1 +++ b/PSDepend/Public/Get-Dependency.ps1 @@ -120,26 +120,13 @@ function Get-Dependency { AnotherPrivatePackage = $morePrivateCredenials } - .LINK - about_PSDepend + .EXAMPLE + Get-Dependency -Path C:\requirements.psd1 - .LINK - about_PSDepend_Definitions + Get dependencies defined in C:\requirements.psd1 .LINK - Get-PSDependScript - - .LINK - Get-PSDependType - - .LINK - Install-Dependency - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding(DefaultParameterSetName = 'File')] param( @@ -154,33 +141,27 @@ function Get-Dependency { [parameter(ParameterSetName='Hashtable')] [hashtable[]]$InputObject, - [parameter(ParameterSetName='File')] - [parameter(ParameterSetName='Hashtable')] - [hashtable]$Credentials + [parameter(ParameterSetName='File')] + [parameter(ParameterSetName='Hashtable')] + [hashtable]$Credentials ) # Helper to pick from global psdependoptions, or return a default function Get-GlobalOption { param( - $Options = $PSDependOptions, + $Options = $PSDependOptions, $Name, $Prefer, $Default = $null ) # Check for preferred value, otherwise try to get value from key, otherwise use default.... $Output = $Default - if($Prefer) - { + if($Prefer) { $Output = $Prefer - } - else - { - try - { + } else { + try { $Output = $Options[$Name] - } - catch - { + } catch { $Output = $Default } } @@ -189,8 +170,7 @@ function Get-Dependency { if( $Name -eq 'Target' -or $Name -eq 'Source' -or $Name -eq 'PreScripts' -or - $Name -eq 'PostScripts') - { + $Name -eq 'PostScripts') { $Output = Inject-Variable $Output } $Output @@ -200,30 +180,29 @@ function Get-Dependency { [cmdletbinding()] param( $Value ) $Output = $Value - switch($Value) - { - {$_ -match '^\.$|^\.\\|^\./'}{ + switch($Value) { + { $_ -match '^\.$|^\.\\|^\./' } { $Output = $Output -replace '^\.', $PWD.Path } - {$_ -Match '\$PWD'} { + { $_ -match '\$PWD' } { $Output = $Output -replace '\$PWD', $PWD.Path } - {$_ -Match '\$ENV:ProgramData'} { + { $_ -match '\$ENV:ProgramData' } { $Output = $Output -replace '\$ENV:ProgramData', $ENV:ProgramData } - {$_ -Match '\$ENV:USERPROFILE'} { + { $_ -match '\$ENV:USERPROFILE' } { $Output = $Output -replace '\$ENV:USERPROFILE', $ENV:USERPROFILE } - {$_ -Match '\$ENV:APPDATA'} { + { $_ -match '\$ENV:APPDATA' } { $Output = $Output -replace '\$ENV:APPDATA', $ENV:APPDATA } - {$_ -Match '\$ENV:TEMP'} { + { $_ -match '\$ENV:TEMP' } { $Output = $Output -replace '\$ENV:TEMP', $ENV:TEMP } - {$_ -Match '\$DependencyFolder|\$DependencyPath'} { + { $_ -match '\$DependencyFolder|\$DependencyPath' } { $DependencyFolder = Split-Path $DependencyFile -Parent $Output = $Output -replace '\$DependencyFolder|\$DependencyPath', $DependencyFolder } @@ -240,25 +219,22 @@ function Get-Dependency { # Global settings.... $PSDependOptions = $null - if($Dependencies.Containskey('PSDependOptions')) - { + if($Dependencies.Containskey('PSDependOptions')) { $PSDependOptions = $Dependencies.PSDependOptions $Dependencies.Remove('PSDependOptions') } - foreach($Dependency in $Dependencies.keys) - { + foreach($Dependency in $Dependencies.keys) { $DependencyHash = $Dependencies.$Dependency $DependencyType = Get-GlobalOption -Name DependencyType - $CredentialName = Get-GlobalOption -Name Credential + $CredentialName = Get-GlobalOption -Name Credential # Look simple syntax with helpers in the key first - If( $DependencyHash -is [string] -and + if( $DependencyHash -is [string] -and $Dependency -match '::' -and ($Dependency -split '::').count -eq 2 - ) - { + ) { [pscustomobject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -273,8 +249,8 @@ function Get-Dependency { Tags = Get-GlobalOption -Name Tags DependsOn = Get-GlobalOption -Name DependsOn PreScripts = Get-GlobalOption -Name PreScripts - PostScripts = Get-GlobalOption -Name PostScripts - PSDependOptions = $PSDependOptions + PostScripts = Get-GlobalOption -Name PostScripts + PSDependOptions = $PSDependOptions Raw = $null } } @@ -283,8 +259,7 @@ function Get-Dependency { elseif( $DependencyHash -is [string] -and $Dependency -notmatch '/' -and -not $DependencyType -or - $DependencyType -eq 'PSGalleryModule') - { + $DependencyType -eq 'PSGalleryModule') { [pscustomobject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -300,18 +275,17 @@ function Get-Dependency { DependsOn = Get-GlobalOption -Name DependsOn PreScripts = Get-GlobalOption -Name PreScripts PostScripts = Get-GlobalOption -Name PostScripts - Credential = Resolve-Credential -Name $CredentialName + Credential = Resolve-Credential -Name $CredentialName PSDependOptions = $PSDependOptions Raw = $null } } # It looks like a git repo, simple syntax, and not a full URI elseif($DependencyHash -is [string] -and - $Dependency -match '/' -and - $Dependency.split('/').count -eq 2 -and - -not $DependencyType -or - $DependencyType -eq 'GitHub') - { + $Dependency -match '/' -and + $Dependency.split('/').count -eq 2 -and + -not $DependencyType -or + $DependencyType -eq 'GitHub') { [pscustomobject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -333,10 +307,9 @@ function Get-Dependency { } # It looks like a git repo, and simple syntax: Git elseif($DependencyHash -is [string] -and - $Dependency -match '/' -and - -not $DependencyType -or - $DependencyType -eq 'Git' ) - { + $Dependency -match '/' -and + -not $DependencyType -or + $DependencyType -eq 'Git' ) { [pscustomobject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -355,47 +328,40 @@ function Get-Dependency { PSDependOptions = $PSDependOptions Raw = $null } - } - else - { + } else { # Parse dependency hash format # Default type is module, unless it's in a git-style format - if(-not $DependencyHash.DependencyType) - { + if(-not $DependencyHash.DependencyType) { # Is it a global option? - if($DependencyType) {} + if($DependencyType) { + } # GitHub first elseif( # Ugly right? Watch out for split called on hashtable... ($Dependency -match '/' -and -not $Dependency.Name -and - ($Dependency -is [string] -and $Dependency.split('/').count -eq 2) + ($Dependency -is [string] -and $Dependency.split('/').count -eq 2) ) -or ($DependencyHash.Name -match '/' -and - ($DependencyHash -is [string] -and $DependencyHash.split('/').count -eq 2) + ($DependencyHash -is [string] -and $DependencyHash.split('/').count -eq 2) ) - ) - { + ) { $DependencyType = 'GitHub' } # Now git... elseif( ($Dependency -match '/' -and -not $Dependency.Name) -or $DependencyHash.Name -match '/' - ) - { + ) { $DependencyType = 'Git' - } - else # finally, psgallerymodule - { + } else { + # finally, psgallerymodule $DependencyType = 'PSGalleryModule' } - } - else - { + } else { $DependencyType = $DependencyHash.DependencyType } - $CredentialName = Get-GlobalOption -Name Credential -Prefer $DependencyHash.Credential + $CredentialName = Get-GlobalOption -Name Credential -Prefer $DependencyHash.Credential [pscustomobject]@{ PSTypeName = 'PSDepend.Dependency' DependencyFile = $DependencyFile @@ -411,53 +377,47 @@ function Get-Dependency { DependsOn = Get-GlobalOption -Name DependsOn -Prefer $DependencyHash.DependsOn PreScripts = Get-GlobalOption -Name PreScripts -Prefer $DependencyHash.PreScripts PostScripts = Get-GlobalOption -Name PostScripts -Prefer $DependencyHash.PostScripts - Credential = Resolve-Credential -Name $CredentialName - PSDependOptions = $PSDependOptions + Credential = Resolve-Credential -Name $CredentialName + PSDependOptions = $PSDependOptions Raw = $DependencyHash } } } - } - - # Heleper to retrieve the credential for a dependency - function Resolve-Credential { - [CmdletBinding()] - param ( - [string]$Name - ) - - $credential = $null - if (($null -ne $Name) -and ($null -ne $Credentials)) { - - if ($Credentials.ContainsKey($Name)) { - $credential = $Credentials[$Name] - } else { - Write-Warning "No credential found for the specified name $Name. Was the dependency misconfigured?" - } - } + } - return $credential - } + # Heleper to retrieve the credential for a dependency + function Resolve-Credential { + [CmdletBinding()] + param ( + [string]$Name + ) - if($PSCmdlet.ParameterSetName -eq 'File') - { - $ParsedDependencies = foreach($DependencyPath in $Path) - { + $credential = $null + if (($null -ne $Name) -and ($null -ne $Credentials)) { + + if ($Credentials.ContainsKey($Name)) { + $credential = $Credentials[$Name] + } else { + Write-Warning "No credential found for the specified name $Name. Was the dependency misconfigured?" + } + } + + return $credential + } + + if($PSCmdlet.ParameterSetName -eq 'File') { + $ParsedDependencies = foreach($DependencyPath in $Path) { #Resolve relative paths... Thanks Oisin! http://stackoverflow.com/a/3040982/3067642 $DependencyPath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($DependencyPath) - if(Test-Path $DependencyPath -PathType Container) - { + if(Test-Path $DependencyPath -PathType Container) { $DependencyFiles = @( Resolve-DependScripts -Path $DependencyPath -Recurse $Recurse ) - } - else - { + } else { $DependencyFiles = @( $DependencyPath ) } $DependencyFiles = $DependencyFiles | Select-Object -Unique - foreach($DependencyFile in $DependencyFiles) - { + foreach($DependencyFile in $DependencyFiles) { # Read the file $Base = Split-Path $DependencyFile -Parent $File = Split-Path $DependencyFile -Leaf @@ -466,23 +426,18 @@ function Get-Dependency { Parse-Dependency -ParamSet $PSCmdlet.ParameterSetName } } - } - elseif($PSCmdlet.ParameterSetName -eq 'Hashtable') - { + } elseif($PSCmdlet.ParameterSetName -eq 'Hashtable') { $DependencyFile = 'Hashtable' - $ParsedDependencies = foreach($InputDependency in $InputObject) - { + $ParsedDependencies = foreach($InputDependency in $InputObject) { $Dependencies = $InputDependency Parse-Dependency -ParamSet $PSCmdlet.ParameterSetName } } - If($PSBoundParameters.ContainsKey('Tags')) - { + if($PSBoundParameters.ContainsKey('Tags')) { $ParsedDependencies = Get-TaggedDependency -Dependency $ParsedDependencies -Tags $Tags - if(-not $ParsedDependencies) - { + if(-not $ParsedDependencies) { Write-Warning "No dependencies found with tags '$tags'" return } diff --git a/PSDepend/Public/Get-PSDependScript.ps1 b/PSDepend/Public/Get-PSDependScript.ps1 index fba005e..d104858 100644 --- a/PSDepend/Public/Get-PSDependScript.ps1 +++ b/PSDepend/Public/Get-PSDependScript.ps1 @@ -1,4 +1,4 @@ -Function Get-PSDependScript { +function Get-PSDependScript { <# .SYNOPSIS Get dependency types and associated scripts @@ -26,29 +26,11 @@ Function Get-PSDependScript { # List dependency types defined in a centralized dependency map .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependType - - .LINK - Install-Dependency - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding()] param( - [validatescript({Test-Path $_ -PathType Leaf -ErrorAction Stop})] + [validatescript({ Test-Path $_ -PathType Leaf -ErrorAction Stop })] [string]$Path = $(Join-Path $ModuleRoot PSDependMap.psd1) ) @@ -58,26 +40,19 @@ Function Get-PSDependScript { $DependencyDefinitions = Import-LocalizedData -BaseDirectory $Base -FileName $File $DependHash = @{} - foreach($DependencyType in $DependencyDefinitions.Keys) - { + foreach($DependencyType in $DependencyDefinitions.Keys) { #Determine the path to this script $Script = $DependencyDefinitions.$DependencyType.Script - if(Test-Path $Script -ErrorAction SilentlyContinue) - { + if(Test-Path $Script -ErrorAction SilentlyContinue) { $ScriptPath = $Script - } - else - { + } else { # account for missing ps1 $ScriptPath = Join-Path $ModuleRoot "PSDependScripts\$($Script -replace ".ps1$").ps1" } - if(test-path $ScriptPath) - { + if(Test-Path $ScriptPath) { $DependHash.$DependencyType = $ScriptPath - } - else - { + } else { Write-Error "Could not find path '$ScriptPath' for dependency $DependencyType. Origin: $($DependencyDefinitions.$DependencyType.Script)" } } diff --git a/PSDepend/Public/Get-PSDependType.ps1 b/PSDepend/Public/Get-PSDependType.ps1 index efa6aab..e356d24 100644 --- a/PSDepend/Public/Get-PSDependType.ps1 +++ b/PSDepend/Public/Get-PSDependType.ps1 @@ -43,25 +43,7 @@ Function Get-PSDependType { # List dependency types defined in a centralized dependency map .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependScript - - .LINK - Install-Dependency - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding()] param( diff --git a/PSDepend/Public/Import-Dependency.ps1 b/PSDepend/Public/Import-Dependency.ps1 index 622550b..25d9488 100644 --- a/PSDepend/Public/Import-Dependency.ps1 +++ b/PSDepend/Public/Import-Dependency.ps1 @@ -30,22 +30,7 @@ Function Import-Dependency { Get dependencies from C:\requirements.psd1 and import them .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependType - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding()] Param( diff --git a/PSDepend/Public/Install-Dependency.ps1 b/PSDepend/Public/Install-Dependency.ps1 index e091914..76f46a8 100644 --- a/PSDepend/Public/Install-Dependency.ps1 +++ b/PSDepend/Public/Install-Dependency.ps1 @@ -33,22 +33,7 @@ Function Install-Dependency { Get dependencies from C:\requirements.psd1 and install them .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependType - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding( SupportsShouldProcess = $True, ConfirmImpact='High' )] @@ -67,6 +52,8 @@ Function Install-Dependency { ) Process { - Invoke-DependencyScript @PSBoundParameters -PSDependAction Install + $InvokeParams = $PSBoundParameters.Clone() + $null = $InvokeParams.Remove('Force') + Invoke-DependencyScript @InvokeParams -PSDependAction Install } } diff --git a/PSDepend/Public/Invoke-DependencyScript.ps1 b/PSDepend/Public/Invoke-DependencyScript.ps1 index 3e492e5..1a52710 100644 --- a/PSDepend/Public/Invoke-DependencyScript.ps1 +++ b/PSDepend/Public/Invoke-DependencyScript.ps1 @@ -1,4 +1,4 @@ -Function Invoke-DependencyScript { +function Invoke-DependencyScript { <# .SYNOPSIS Invoke a dependency script @@ -33,32 +33,17 @@ Function Invoke-DependencyScript { Get dependencies from C:\requirements.psd1 and import them .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependType - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding()] - Param( + param( [parameter( ValueFromPipeline = $True, - ParameterSetName='Map', - Mandatory = $True)] + ParameterSetName='Map', + Mandatory = $True)] [PSTypeName('PSDepend.Dependency')] [psobject]$Dependency, - [validatescript({Test-Path -Path $_ -PathType Leaf -ErrorAction Stop})] + [validatescript({ Test-Path -Path $_ -PathType Leaf -ErrorAction Stop })] [string]$PSDependTypePath = $(Join-Path $ModuleRoot PSDependMap.psd1), [string[]]$PSDependAction, @@ -67,14 +52,12 @@ Function Invoke-DependencyScript { [switch]$Quiet ) - Begin - { + begin { # This script reads a depend.psd1, installs dependencies as defined Write-Verbose "Running Invoke-DependencyScript with ParameterSetName '$($PSCmdlet.ParameterSetName)' and params: $($PSBoundParameters | Out-String)" $PSDependTypes = Get-PSDependType -SkipHelp } - Process - { + process { Write-Verbose "Dependencies:`n$($Dependency | Select-Object -Property * | Out-String)" #Get definitions, and dependencies in this particular psd1 @@ -82,21 +65,18 @@ Function Invoke-DependencyScript { $TheseDependencyTypes = @( $Dependency.DependencyType | Sort-Object -Unique ) #Build up hash, we call each dependencytype script for applicable dependencies - foreach($DependencyType in $TheseDependencyTypes) - { - $PSDependType = ($PSDependTypes | Where-Object {$_.DependencyType -eq $DependencyType}) - if(-not $PSDependType.Supported) - { + foreach($DependencyType in $TheseDependencyTypes) { + $PSDependType = ($PSDependTypes | Where-Object { $_.DependencyType -eq $DependencyType }) + if(-not $PSDependType.Supported) { Write-Warning "Skipping dependency type [$DependencyType]`nThis dependency does not support your platform`nSupported platforms: [$($PSDependType.Supports)]" continue } $DependencyScript = $DependencyDefs.$DependencyType - if(-not $DependencyScript) - { + if(-not $DependencyScript) { Write-Error "DependencyType $DependencyType is not defined in PSDependMap.psd1" continue } - $TheseDependencies = @( $Dependency | Where-Object {$_.DependencyType -eq $DependencyType}) + $TheseDependencies = @( $Dependency | Where-Object { $_.DependencyType -eq $DependencyType }) #Define params for the script #Each dependency type can have a hashtable to splat. @@ -104,101 +84,75 @@ Function Invoke-DependencyScript { $ValidParamNames = $RawParameters.Name Write-Verbose "Found parameters [$ValidParamNames]" - if($ValidParamNames -notcontains 'PSDependAction') - { + if($ValidParamNames -notcontains 'PSDependAction') { Write-Error "No PSDependAction found on PSDependScript [$DependencyScript]. Skipping [$($Dependency.DependencyName)]" continue } [string[]]$ValidPSDependActions = $RawParameters | - Where-Object {$_.Name -like 'PSDependAction'} | + Where-Object { $_.Name -like 'PSDependAction' } | Select-Object -ExpandProperty ValidateSetValues -ErrorAction SilentlyContinue - [string[]]$PSDependActions = foreach($Action in $PSDependAction) - { - if($ValidPSDependActions -contains $Action) {$Action} - else - { + [string[]]$PSDependActions = foreach($Action in $PSDependAction) { + if($ValidPSDependActions -contains $Action) { + $Action + } else { Write-Warning "Skipping PSDependAction [$Action] for dependency [$($Dependency.DependencyName)]. Valid actions: [$ValidPSDependActions]" } } - if($PSDependActions.count -like 0) - { + if($PSDependActions.count -like 0) { Write-Verbose "Skipped dependency [$($Dependency.DependencyName)] due to filtered PSDependAction. See Warnings above." continue } - if($PSDependActions -contains 'Test' -and ( $PSDependActions -contains 'Import' -or $PSDependActions -contains 'Install')) - { + if($PSDependActions -contains 'Test' -and ( $PSDependActions -contains 'Import' -or $PSDependActions -contains 'Install')) { Write-Error "Removing [Test] from PSDependActions. The Test action must run on its own." - $PSDependActions = $PSDependActions | Where-Object {$_ -ne 'Test'} + $PSDependActions = $PSDependActions | Where-Object { $_ -ne 'Test' } } - foreach($ThisDependency in $TheseDependencies) - { + foreach($ThisDependency in $TheseDependencies) { #Parameters for dependency types. Only accept valid params... - if($ThisDependency.Parameters.keys.count -gt 0) - { + if($ThisDependency.Parameters.keys.count -gt 0) { $splat = @{} - foreach($key in $ThisDependency.Parameters.keys) - { - if($ValidParamNames -contains $key) - { + foreach($key in $ThisDependency.Parameters.keys) { + if($ValidParamNames -contains $key) { $splat.Add($key, $ThisDependency.Parameters.$key) - } - else - { + } else { Write-Warning "Parameter [$Key] with value [$($ThisDependency.Parameters.$Key)] is not a valid parameter for [$DependencyType], ignoring. Valid params:`n[$ValidParamNames]" } } - if($ThisDependency.Parameters.Import -and $PSDependActions -notcontains 'Test') - { + if($ThisDependency.Parameters.Import -and $PSDependActions -notcontains 'Test') { $PSDependActions += 'Import' $PSDependActions = $PSDependActions | Sort-Object -Unique } - if($splat.ContainsKey('PSDependAction')) - { + if($splat.ContainsKey('PSDependAction')) { $Splat['PSDependAction'] = $PSDependActions - } - else - { + } else { $Splat.add('PSDependAction', $PSDependActions) } - } - else - { - $splat = @{PSDependAction = $PSDependActions} + } else { + $splat = @{PSDependAction = $PSDependActions } } #Define params for the script $splat.add('Dependency', $ThisDependency) # PITA, but tasks can run two ways, each different than typical dependency scripts - if($PSDependActions -contains 'Install' -and $DependencyType -eq 'Task') - { - foreach($TaskScript in $ThisDependency.Target) - { - if( Test-Path $TaskScript -PathType Leaf) - { + if($PSDependActions -contains 'Install' -and $DependencyType -eq 'Task') { + foreach($TaskScript in $ThisDependency.Target) { + if( Test-Path $TaskScript -PathType Leaf) { . $TaskScript @splat - } - else - { + } else { Write-Error "Could not process task [$TaskScript].`nAre connectivity, privileges, and other needs met to access it?" } } - } - else - { + } else { Write-Verbose "Invoking '$DependencyScript' with parameters $($Splat | Out-String)" $Output = . $DependencyScript @splat - if($PSDependActions -contains 'Test' -and -not $Quiet) - { + if($PSDependActions -contains 'Test' -and -not $Quiet) { Add-Member -InputObject $ThisDependency -MemberType NoteProperty -Name DependencyExists -Value $Output -Force -PassThru - } - else - { + } else { $Output } } diff --git a/PSDepend/Public/Invoke-PSDepend.ps1 b/PSDepend/Public/Invoke-PSDepend.ps1 index d46d329..b1b51b3 100644 --- a/PSDepend/Public/Invoke-PSDepend.ps1 +++ b/PSDepend/Public/Invoke-PSDepend.ps1 @@ -96,19 +96,7 @@ Function Invoke-PSDepend { # Find and run *.depend.psd1 and requirements.psd1 files under C\Requirements (but not subfolders) .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Install-Dependency - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding( DefaultParameterSetName = 'installimport-file', SupportsShouldProcess = $True, diff --git a/PSDepend/Public/Test-Dependency.ps1 b/PSDepend/Public/Test-Dependency.ps1 index b49dfe6..fb433d5 100644 --- a/PSDepend/Public/Test-Dependency.ps1 +++ b/PSDepend/Public/Test-Dependency.ps1 @@ -1,4 +1,4 @@ -Function Test-Dependency { +function Test-Dependency { <# .SYNOPSIS Test a specific dependency @@ -34,40 +34,24 @@ Function Test-Dependency { Get dependencies from C:\requirements.psd1 and test whether they exist .LINK - about_PSDepend - - .LINK - about_PSDepend_Definitions - - .LINK - Get-Dependency - - .LINK - Get-PSDependType - - .LINK - Invoke-PSDepend - - .LINK - https://github.com/RamblingCookieMonster/PSDepend + https://github.com/PowerShellOrg/PSDepend #> [cmdletbinding()] - Param( + param( [parameter( ValueFromPipeline = $True, - ParameterSetName='Map', - Mandatory = $True)] + ParameterSetName='Map', + Mandatory = $True)] [PSTypeName('PSDepend.Dependency')] [psobject[]]$Dependency, - [validatescript({Test-Path -Path $_ -PathType Leaf -ErrorAction Stop})] + [validatescript({ Test-Path -Path $_ -PathType Leaf -ErrorAction Stop })] [string]$PSDependTypePath = $(Join-Path $ModuleRoot PSDependMap.psd1), [string[]]$Tags, [switch]$Quiet ) - process - { + process { Invoke-DependencyScript @PSBoundParameters -PSDependAction Test } } diff --git a/Tests/Help.tests.ps1 b/Tests/Help.tests.ps1 index 90651b0..9b71829 100644 --- a/Tests/Help.tests.ps1 +++ b/Tests/Help.tests.ps1 @@ -39,7 +39,7 @@ Describe "Test help for <_.Name>" -ForEach $commands { $commandHelp = Get-Help $command.Name -ErrorAction SilentlyContinue $commandParameters = global:FilterOutCommonParams -Params $command.ParameterSets.Parameters $commandParameterNames = $commandParameters.Name - $helpLinks = $commandHelp.relatedLinks.navigationLink.uri + $helpLinks = @($commandHelp.relatedLinks.navigationLink.uri | Where-Object { $_ }) $helpParameters = global:FilterOutCommonParams -Params $commandHelp.Parameters.Parameter $helpParameterNames = $helpParameters.Name } diff --git a/Tests/PSDepend.Tests.ps1 b/Tests/PSDepend.Tests.ps1 index c7bad9e..cbdb7fb 100644 --- a/Tests/PSDepend.Tests.ps1 +++ b/Tests/PSDepend.Tests.ps1 @@ -186,14 +186,14 @@ Describe "Install-Dependency PS$PSVersion" -Tag 'Unit' { Context 'PSGalleryModule install' { BeforeAll { Set-StrictMode -Version latest - Mock Install-Module {} + Mock Install-Module {} -ModuleName PSDepend } AfterAll { Set-StrictMode -Off } It 'Calls Install-Module when given a PSGalleryModule dependency via pipeline' { Get-Dependency -Path $TestDepends\psgallerymodule.depend.psd1 | Install-Dependency -Force - Should -Invoke Install-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 1 -Exactly -ModuleName PSDepend } } } @@ -218,7 +218,7 @@ Describe "Invoke-DependencyScript PS$PSVersion" -Tag 'Unit' { Context 'Test action' { BeforeAll { Set-StrictMode -Version latest - Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } } + Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } } -ModuleName PSDepend } AfterAll { Set-StrictMode -Off } diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 691191d..7385bbe 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -46,12 +46,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Modules' { BeforeAll { - Mock Install-Module { return $true } + Mock Install-Module { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" -Force } It 'Should execute Install-Module' { - Should -Invoke Install-Module -Times 1 -Exactly -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -61,12 +61,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Modules with credentials' { BeforeAll { - Mock Install-Module { return $true } + Mock Install-Module { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.withcredentials.depend.psd1" -Force -Credentials $Credentials } It 'Should execute Install-Module' { - Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -76,13 +76,13 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Modules with multiple credentials' { BeforeAll { - Mock Install-Module { return $true } + Mock Install-Module { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.multiplecredentials.depend.psd1" -Force -Credentials $Credentials } It 'Should execute Install-Module with the correct credentials' { - Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'imaginary' -and $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context - Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'other' -and $Credential -ne $null -and $Credential.Username -eq 'otherUser' } -Scope Context + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'imaginary' -and $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context -ModuleName PSDepend + Should -Invoke Install-Module -Times 1 -Exactly -ParameterFilter { $Name -eq 'other' -and $Credential -ne $null -and $Credential.Username -eq 'otherUser' } -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -92,12 +92,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Saves Modules' { BeforeAll { - Mock Save-Module { return $true } + Mock Save-Module { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.depend.psd1" -Force } It 'Should execute Save-Module' { - Should -Invoke Save-Module -Times 1 -Exactly -Scope Context + Should -Invoke Save-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -107,12 +107,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Saves Modules with credentials' { BeforeAll { - Mock Save-Module { return $true } + Mock Save-Module { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends/savemodule.withcredentials.depend.psd1" -Force -Credentials $Credentials } It 'Should execute Save-Module' { - Should -Invoke Save-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context + Should -Invoke Save-Module -Times 1 -Exactly -ParameterFilter { $Credential -ne $null -and $Credential.Username -eq 'testUser' } -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -122,7 +122,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Repository does not Exist' { BeforeAll { - Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah' } + Mock Install-Module { throw "Unable to find repository 'Blah'" } -ParameterFilter { $Repository -eq 'Blah' } -ModuleName PSDepend } It 'Throws because Repository could not be found' { @@ -133,97 +133,97 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Same module version exists (Version)' { BeforeAll { - Mock Install-Module {} + Mock Install-Module {} -ModuleName PSDepend Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } - } - Mock Find-Module + } -ModuleName PSDepend + Mock Find-Module -ModuleName PSDepend } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Module -Times 1 -Exactly - Should -Invoke Find-Module -Times 0 -Exactly - Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-Module -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Install-Module -Times 0 -Exactly -ModuleName PSDepend } } Context 'Same module version exists (SemVersion)' { BeforeAll { - Mock Install-Module {} + Mock Install-Module {} -ModuleName PSDepend Mock Get-Module { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } - Mock Find-Module + } -ModuleName PSDepend + Mock Find-Module -ModuleName PSDepend } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Module -Times 1 -Exactly - Should -Invoke Find-Module -Times 0 -Exactly - Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-Module -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Install-Module -Times 0 -Exactly -ModuleName PSDepend } } Context 'Latest module required, and already installed (version)' { BeforeAll { - Mock Install-Module {} + Mock Install-Module {} -ModuleName PSDepend Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Module -Times 1 -Exactly - Should -Invoke Find-Module -Times 1 -Exactly - Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Install-Module -Times 0 -Exactly -ModuleName PSDepend } } Context 'Latest module required, and already installed (SemVersion)' { BeforeAll { - Mock Install-Module {} + Mock Install-Module {} -ModuleName PSDepend Mock Get-Module { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend } It 'Skips Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Module -Times 1 -Exactly - Should -Invoke Find-Module -Times 1 -Exactly - Should -Invoke Install-Module -Times 0 -Exactly + Should -Invoke Get-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-Module -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Install-Module -Times 0 -Exactly -ModuleName PSDepend } } Context 'Test-Dependency' { BeforeEach { - Mock Install-Module {} - Mock Find-Module {} + Mock Install-Module {} -ModuleName PSDepend + Mock Find-Module {} -ModuleName PSDepend } It 'Returns $true when it finds an existing module (Version)' { @@ -231,7 +231,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -243,7 +243,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -255,12 +255,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -272,12 +272,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -285,7 +285,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It "Returns `$false when it doesn't find an existing module (Version)" { - Mock Get-Module { $null } + Mock Get-Module { $null } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -293,7 +293,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It "Returns `$false when it doesn't find an existing module (SemVersion)" { - Mock Get-Module { $null } + Mock Get-Module { $null } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -305,7 +305,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.4' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -317,7 +317,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5-preview0001' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -329,7 +329,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.4' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.SameSemanticVersion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -341,12 +341,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.4' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -358,12 +358,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.2.5-preview0001' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5-preview0002' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.latestversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -373,20 +373,20 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Imports dependencies' { BeforeAll { - Mock Install-Module {} - Mock Import-Module + Mock Install-Module {} -ModuleName PSDepend + Mock Import-Module -ModuleName PSDepend } It 'Runs Import-Module when import is specified' { $Results = Get-Dependency @Verbose -Path "$TestDepends/psgallerymodule.depend.psd1" | Import-Dependency @Verbose - Should -Invoke Import-Module -Times 1 -Exactly -Scope Context - Should -Invoke Install-Module -Times 0 -Exactly -Scope Context + Should -Invoke Import-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Install-Module -Times 0 -Exactly -Scope Context -ModuleName PSDepend } } Context 'AddToPath on install of module to target folder' { BeforeAll { - Mock Save-Module { $True } + Mock Save-Module { $True } -ModuleName PSDepend } AfterEach { @@ -413,18 +413,18 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { ) BeforeAll { - Mock Install-Module - Mock Import-Module + Mock Install-Module -ModuleName PSDepend + Mock Import-Module -ModuleName PSDepend Mock Get-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend Mock Find-Module { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend } AfterEach { @@ -438,8 +438,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Invoke-PSDepend @Verbose -Path "$TestDepends\$DependPsd1File" -Import -Force -ErrorAction Stop # check assumption that expected code path was followed... - Should -Invoke Install-Module -Times 0 -Exactly - Should -Invoke Import-Module -Times 1 -Exactly + Should -Invoke Install-Module -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Import-Module -Times 1 -Exactly -ModuleName PSDepend # then ($env:PSModulePath -split ([IO.Path]::PathSeparator)) -contains $script:SavePath | Should -Be $True @@ -448,14 +448,14 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'SkipPublisherCheck' { BeforeAll { - Mock Get-PSRepository { return $true } - Mock Install-Module {} + Mock Get-PSRepository { return $true } -ModuleName PSDepend + Mock Install-Module {} -ModuleName PSDepend } It 'Supplies SkipPublisherCheck switch to Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.skippubcheck.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Install-Module -Times 1 -Exactly -Scope Context - Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ParameterFilter { + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend -ParameterFilter { $SkipPublisherCheck -eq $true } } @@ -463,14 +463,14 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'AllowPrerelease' { BeforeAll { - Mock Get-PSRepository { return $true } - Mock Install-Module {} + Mock Get-PSRepository { return $true } -ModuleName PSDepend + Mock Install-Module {} -ModuleName PSDepend } It 'Supplies AllowPrerelease switch to Install-Module' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerymodule.AllowPrerelease.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Install-Module -Times 1 -Exactly -Scope Context - Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ParameterFilter { + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Install-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend -ParameterFilter { $AllowPrerelease -eq $true } } @@ -887,14 +887,14 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Packages' { BeforeAll { - Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } - Mock Get-Package - Mock Install-Package { $True } + Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } -ModuleName PSDepend + Mock Get-Package -ModuleName PSDepend + Mock Install-Package { $True } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\package.depend.psd1" -Force } It 'Should execute Install-Package' { - Should -Invoke Install-Package -Times 1 -Exactly -Scope Context + Should -Invoke Install-Package -Times 1 -Exactly -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -903,8 +903,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } Context 'PackageSource does not Exist' { BeforeAll { - Mock Install-Package - Mock Get-PackageSource + Mock Install-Package -ModuleName PSDepend + Mock Get-PackageSource -ModuleName PSDepend } It 'Throws because Repository could not be found' { @@ -921,21 +921,21 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) } - Mock Install-Package + Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ Version = '1.1' } - } - Mock Find-Package + } -ModuleName PSDepend + Mock Find-Package -ModuleName PSDepend } It 'Skips Install-Package' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Package -Times 1 -Exactly -Scope Context - Should -Invoke Find-Package -Times 0 -Exactly -Scope Context - Should -Invoke Install-Package -Times 0 -Exactly -Scope Context + Should -Invoke Get-Package -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Find-Package -Times 0 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Install-Package -Times 0 -Exactly -Scope Context -ModuleName PSDepend } } @@ -947,25 +947,25 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { function Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) } - Mock Install-Package + Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend Mock Find-Package { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend } It 'Runs Get-Package and Find-Package, skips Install-Package' { Invoke-PSDepend @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-Package -Times 1 -Exactly -Scope Context - Should -Invoke Find-Package -Times 1 -Exactly -Scope Context - Should -Invoke Install-Package -Times 0 -Exactly -Scope Context + Should -Invoke Get-Package -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Find-Package -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Install-Package -Times 0 -Exactly -Scope Context -ModuleName PSDepend } } @@ -987,8 +987,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } BeforeEach { - Mock Install-Package {} - Mock Find-Package {} + Mock Install-Package {} -ModuleName PSDepend + Mock Find-Package {} -ModuleName PSDepend } It 'Returns $true when it finds an existing module' { @@ -996,7 +996,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.Count | Should -Be 1 @@ -1008,12 +1008,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend Mock Find-Package { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.Count | Should -Be 1 @@ -1021,7 +1021,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It "Returns `$false when it doesn't find an existing module" { - Mock Get-Package { $null } + Mock Get-Package { $null } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.Count | Should -Be 1 @@ -1033,7 +1033,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.0' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.sameversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.Count | Should -Be 1 @@ -1045,12 +1045,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ Version = '1.0' } - } + } -ModuleName PSDepend Mock Find-Package { [pscustomobject]@{ Version = '1.1' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\package.latestversion.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.Count | Should -Be 1 @@ -1088,8 +1088,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Dependency' { BeforeAll { - Mock Get-NodeModule { return $null } - Mock Install-NodeModule {} + Mock Get-NodeModule { return $null } -ModuleName PSDepend + Mock Install-NodeModule {} -ModuleName PSDepend Mock New-Item { return true } Mock Push-Location Mock Pop-Location @@ -1107,13 +1107,13 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Invokes the Npm dependency type' { - Should -Invoke Install-NodeModule -Times 2 -Exactly -Scope Context + Should -Invoke Install-NodeModule -Times 2 -Exactly -Scope Context -ModuleName PSDepend } } Context 'Tests Dependency' { BeforeAll { - Mock Install-NodeModule {} + Mock Install-NodeModule {} -ModuleName PSDepend Mock New-Item { return true } Mock Push-Location Mock Pop-Location @@ -1122,7 +1122,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Returns $false if the module is not installed' { - Mock Get-NodeModule { return $null } + Mock Get-NodeModule { return $null } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $false } @@ -1131,12 +1131,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { 'gitbook-cli' = @{ version = '2.3.0' } - } } -ParameterFilter { $Target -eq 'Global' } + } } -ParameterFilter { $Target -eq 'Global' } -ModuleName PSDepend Mock Get-NodeModule { return [pscustomobject]@{ 'gitbook-summary' = @{ version = '1.2.3' } - } } + } } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Test -Quiet | Should -Be $true } } @@ -1172,18 +1172,18 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Installs the .NET Core SDK to the specified directory' { - Mock Test-Dotnet { return $false } + Mock Test-Dotnet { return $false } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force Test-Path $script:SavePath | Should -BeTrue } It 'Does nothing if the .NET Core SDK is found' { - Mock Test-Dotnet { return $true } - Mock Install-Dotnet + Mock Test-Dotnet { return $true } -ModuleName PSDepend + Mock Install-Dotnet -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force - Should -Invoke Install-Dotnet -Times 0 -Exactly + Should -Invoke Install-Dotnet -Times 0 -Exactly -ModuleName PSDepend } AfterAll { @@ -1193,9 +1193,9 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Tests Dependency' { BeforeAll { - Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } - Mock Test-Path { return $true } -ParameterFilter { $Path -eq (Join-Path $script:GlobalDotnetSdkLocation $script:DotnetFile) } - Mock Get-DotnetVersion { return '2.1.330-rc1' } + Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } -ModuleName PSDepend + Mock Test-Path { return $true } -ParameterFilter { $Path -eq (Join-Path $script:GlobalDotnetSdkLocation $script:DotnetFile) } -ModuleName PSDepend + Mock Get-DotnetVersion { return '2.1.330-rc1' } -ModuleName PSDepend } It 'Can propertly compare semantic versions' { @@ -1208,7 +1208,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Imports Dependency' { BeforeAll { - Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } + Mock Get-Command { return $false } -ParameterFilter { $Name -eq 'dotnet' } -ModuleName PSDepend $script:originalPath = $env:PATH } @@ -1217,19 +1217,19 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Can add the Target of the .NET Core SDK to the PATH' { - Mock Test-Dotnet { return $true } + Mock Test-Dotnet { return $true } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.complex.depend.psd1" -Force -Import -ErrorAction Stop ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $script:SavePath } It 'Can add the global path of the .NET Core SDK to the PATH' { - Mock Test-Dotnet { return $true } + Mock Test-Dotnet { return $true } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.simple.depend.psd1" -Force -Import -ErrorAction Stop ($env:PATH -split [IO.Path]::PathSeparator)[0] | Should -Be $script:GlobalDotnetSdkLocation } It 'Throws if the path cannot be found' { - Mock Test-Dotnet { return $false } + Mock Test-Dotnet { return $false } -ModuleName PSDepend { Invoke-PSDepend @Verbose -Path "$TestDepends\dotnetsdk.simple.depend.psd1" -Force -Import -ErrorAction Stop } | Should -Throw -ExpectedMessage ".NET SDK cannot be located. Try installing using PSDepend." } From bb9051b543caab96116207a51d285508f189fb31 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 22:42:06 -0700 Subject: [PATCH 17/22] fix: resolve remaining Pester v5 migration failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use @{} + $PSBoundParameters instead of .Clone() to copy PSBoundParameters into a mutable hashtable (PSBoundParametersDictionary has no Clone method) - Inject stub functions for PackageManagement commands into PSDepend's module scope via & (Get-Module PSDepend) { ... } so -ModuleName PSDepend mocks can resolve them; remove now-redundant inline function redefinitions in individual Package contexts; add AfterAll cleanup - Add -ModuleName PSDepend to all mocks in Git, FileDownload, PSGalleryNuget, and FileSystem Describe blocks — these are Windows-only sections where Invoke-ExternalCommand, Get-WebFile, Find-NugetPackage, Copy-Item, Import-LocalizedData, Import-Module, Test-Path, New-Item, Push-Location, Pop-Location, and Set-Location all resolve inside PSDepend's module scope - Fix Npm: add -ModuleName PSDepend to Push-Location and Pop-Location in both Npm contexts; fix `return true` string bug to `return $true` Co-Authored-By: Claude Sonnet 4.6 --- PSDepend/Public/Install-Dependency.ps1 | 2 +- Tests/PSModuleGallery.Type.Tests.ps1 | 198 +++++++++++-------------- 2 files changed, 90 insertions(+), 110 deletions(-) diff --git a/PSDepend/Public/Install-Dependency.ps1 b/PSDepend/Public/Install-Dependency.ps1 index 76f46a8..35fcdb9 100644 --- a/PSDepend/Public/Install-Dependency.ps1 +++ b/PSDepend/Public/Install-Dependency.ps1 @@ -52,7 +52,7 @@ Function Install-Dependency { ) Process { - $InvokeParams = $PSBoundParameters.Clone() + $InvokeParams = @{} + $PSBoundParameters $null = $InvokeParams.Remove('Force') Invoke-DependencyScript @InvokeParams -PSDependAction Install } diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 7385bbe..362df6f 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -489,12 +489,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { PSB = $PSBoundParameters Arg = $Args } - } -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } - Mock New-Item { return $true } - Mock Push-Location {} - Mock Pop-Location {} - Mock Set-Location {} - Mock Test-Path { return $False } -ParameterFilter { $Path -match "Invoke-Build$|PSDeploy$" } + } -ModuleName PSDepend -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } + Mock New-Item { return $true } -ModuleName PSDepend + Mock Push-Location {} -ModuleName PSDepend + Mock Pop-Location {} -ModuleName PSDepend + Mock Set-Location {} -ModuleName PSDepend + Mock Test-Path { return $False } -ModuleName PSDepend -ParameterFilter { $Path -match "Invoke-Build$|PSDeploy$" } $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\git.depend.psd1" $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\git.depend.psd1" -Force @@ -508,29 +508,29 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Invokes the Git dependency type' { - Should -Invoke Invoke-ExternalCommand -Times 6 -Exactly -Scope Context + Should -Invoke Invoke-ExternalCommand -Times 6 -Exactly -Scope Context -ModuleName PSDepend } } Context 'Tests dependency' { BeforeAll { - Mock New-Item { return $true } - Mock Push-Location {} - Mock Pop-Location {} - Mock Set-Location {} - Mock Invoke-ExternalCommand -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } + Mock New-Item { return $true } -ModuleName PSDepend + Mock Push-Location {} -ModuleName PSDepend + Mock Pop-Location {} -ModuleName PSDepend + Mock Set-Location {} -ModuleName PSDepend + Mock Invoke-ExternalCommand -ModuleName PSDepend -ParameterFilter { $Arguments -contains 'checkout' -or $Arguments -contains 'clone' } } It 'Returns $false if git repo does not exist' { - Mock Test-Path { return $False } -ParameterFilter { $Path -match "PSDeploy$" } + Mock Test-Path { return $False } -ModuleName PSDepend -ParameterFilter { $Path -match "PSDeploy$" } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.count | Should -Be 1 $Results[0] | Should -Be $False } It 'Returns $true if git repo does exist' { - Mock Test-Path { return $true } -ParameterFilter { $Path -match "PSDeploy$" } - Mock Invoke-ExternalCommand { return 'imaginary_branch' } -ParameterFilter { $Arguments -contains 'rev-parse' } + Mock Test-Path { return $true } -ModuleName PSDepend -ParameterFilter { $Path -match "PSDeploy$" } + Mock Invoke-ExternalCommand { return 'imaginary_branch' } -ModuleName PSDepend -ParameterFilter { $Arguments -contains 'rev-parse' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\git.test.depend.psd1" | Test-Dependency @Verbose -Quiet ) $Results.count | Should -Be 1 $Results[0] | Should -Be $true @@ -550,7 +550,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { PSB = $PSBoundParameters Arg = $Args } - } + } -ModuleName PSDepend $script:Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1") } @@ -561,13 +561,13 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { It 'Invokes the FileDownload dependency type' { Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force - Should -Invoke Get-WebFile -Times 1 -Exactly + Should -Invoke Get-WebFile -Times 1 -Exactly -ModuleName PSDepend } It 'Parses URL file name and skips on existing' { New-Item -ItemType File -Path (Join-Path $script:SavePath 'System.Data.SQLite.dll') -Force Invoke-PSDepend @Verbose -Path "$TestDepends\filedownload.depend.psd1" -Force - Should -Invoke Get-WebFile -Times 0 -Exactly + Should -Invoke Get-WebFile -Times 0 -Exactly -ModuleName PSDepend } } @@ -578,20 +578,20 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Returns $false if file does not exist' { - Mock Get-WebFile {} + Mock Get-WebFile {} -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1" | Test-Dependency @Verbose -Quiet) $Results.count | Should -Be 1 $Results[0] | Should -Be $False - Should -Invoke Get-WebFile -Times 0 -Exactly + Should -Invoke Get-WebFile -Times 0 -Exactly -ModuleName PSDepend } It 'Returns $true if file does exist' { New-Item -ItemType File -Path (Join-Path $script:SavePath 'System.Data.SQLite.dll') -Force - Mock Get-WebFile {} + Mock Get-WebFile {} -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filedownload.depend.psd1" | Test-Dependency @Verbose -Quiet) $Results.count | Should -Be 1 $Results[0] | Should -Be $true - Should -Invoke Get-WebFile -Times 0 -Exactly + Should -Invoke Get-WebFile -Times 0 -Exactly -ModuleName PSDepend } } } @@ -603,14 +603,14 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs Modules' { BeforeAll { - Mock Test-Path { return $true } -ParameterFilter { $PathType -eq 'Container' } - Mock Invoke-ExternalCommand { return $true } - Mock Find-NugetPackage { return $true } + Mock Test-Path { return $true } -ModuleName PSDepend -ParameterFilter { $PathType -eq 'Container' } + Mock Invoke-ExternalCommand { return $true } -ModuleName PSDepend + Mock Find-NugetPackage { return $true } -ModuleName PSDepend $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" -Force } It 'Should execute Invoke-ExternalCommand' { - Should -Invoke Invoke-ExternalCommand -Times 1 -Exactly -Scope Context + Should -Invoke Invoke-ExternalCommand -Times 1 -Exactly -Scope Context -ModuleName PSDepend } It 'Should Return Mocked output' { @@ -620,56 +620,56 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Same module version exists' { BeforeAll { - Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } - Mock Invoke-ExternalCommand {} + Mock Test-Path { return $True } -ModuleName PSDepend -ParameterFilter { $Path -match 'jenkins' } + Mock Invoke-ExternalCommand {} -ModuleName PSDepend Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } - Mock Find-NugetPackage + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } + Mock Find-NugetPackage -ModuleName PSDepend } It 'Skips Invoke-ExternalCommand' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Import-LocalizedData -Times 1 -Exactly - Should -Invoke Find-NugetPackage -Times 0 -Exactly - Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-LocalizedData -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-NugetPackage -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -ModuleName PSDepend } } Context 'Latest module required, and already installed' { BeforeAll { - Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } - Mock Invoke-ExternalCommand {} + Mock Test-Path { return $True } -ModuleName PSDepend -ParameterFilter { $Path -match 'jenkins' } + Mock Invoke-ExternalCommand {} -ModuleName PSDepend Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend } It 'Skips Invoke-ExternalCommand' { Invoke-PSDepend @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Import-LocalizedData -Times 1 -Exactly - Should -Invoke Find-NugetPackage -Times 1 -Exactly - Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly + Should -Invoke Import-LocalizedData -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Find-NugetPackage -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -ModuleName PSDepend } } Context 'Tests dependencies' { BeforeEach { - Mock Invoke-ExternalCommand {} - Mock Test-Path { return $True } -ParameterFilter { $Path -match 'jenkins' } - Mock Find-NugetPackage {} + Mock Invoke-ExternalCommand {} -ModuleName PSDepend + Mock Test-Path { return $True } -ModuleName PSDepend -ParameterFilter { $Path -match 'jenkins' } + Mock Find-NugetPackage {} -ModuleName PSDepend } It 'Returns $true when it finds an existing module' { @@ -677,7 +677,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -689,12 +689,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -702,7 +702,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It "Returns `$false when it doesn't find an existing module" { - Mock Import-LocalizedData -ParameterFilter { $FileName -eq 'jenkins.psd1' } + Mock Import-LocalizedData -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) $Results.Count | Should -Be 1 @@ -714,7 +714,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ ModuleVersion = '1.2.4' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.sameversion.depend.psd1" | Test-Dependency -Quiet ) @@ -727,12 +727,12 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { [pscustomobject]@{ ModuleVersion = '1.2.4' } - } -ParameterFilter { $FileName -eq 'jenkins.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'jenkins.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.latestversion.depend.psd1" | Test-Dependency -Quiet ) @@ -743,21 +743,21 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Imports dependencies' { BeforeAll { - Mock Invoke-ExternalCommand { $True } - Mock Import-Module + Mock Invoke-ExternalCommand { $True } -ModuleName PSDepend + Mock Import-Module -ModuleName PSDepend } It 'Runs Import-Module when import is specified' { $Results = Get-Dependency @Verbose -Path "$TestDepends\psgallerynuget.depend.psd1" | Import-Dependency @Verbose - Should -Invoke Import-Module -Times 1 -Exactly -Scope Context - Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -Scope Context + Should -Invoke Import-Module -Times 1 -Exactly -Scope Context -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -Scope Context -ModuleName PSDepend } } Context 'AddToPath on install of module to target folder' { BeforeAll { - Mock Invoke-ExternalCommand { $True } - Mock Import-Module + Mock Invoke-ExternalCommand { $True } -ModuleName PSDepend + Mock Import-Module -ModuleName PSDepend } AfterEach { @@ -784,19 +784,19 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { ) BeforeAll { - Mock Test-Path { return $True } -ParameterFilter { $Path -match 'imaginary' } - Mock Invoke-ExternalCommand {} - Mock Import-Module + Mock Test-Path { return $True } -ModuleName PSDepend -ParameterFilter { $Path -match 'imaginary' } + Mock Invoke-ExternalCommand {} -ModuleName PSDepend + Mock Import-Module -ModuleName PSDepend Mock Import-LocalizedData { [pscustomobject]@{ ModuleVersion = '1.2.5' } - } -ParameterFilter { $FileName -eq 'imaginary.psd1' } + } -ModuleName PSDepend -ParameterFilter { $FileName -eq 'imaginary.psd1' } Mock Find-NugetPackage { [pscustomobject]@{ Version = '1.2.5' } - } + } -ModuleName PSDepend } AfterEach { @@ -810,8 +810,8 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Invoke-PSDepend @Verbose -Path "$TestDepends\$DependPsd1File" -Import -Force -ErrorAction Stop # check assumption that expected code path was followed... - Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly - Should -Invoke Import-Module -Times 1 -Exactly + Should -Invoke Invoke-ExternalCommand -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Import-Module -Times 1 -Exactly -ModuleName PSDepend # then (($env:PSModulePath -split ([IO.Path]::PathSeparator))) -contains $script:SavePath | Should -Be $True @@ -826,7 +826,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Installs dependency' { BeforeAll { - Mock Copy-Item + Mock Copy-Item -ModuleName PSDepend $script:Dependencies = @(Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1") } @@ -837,13 +837,13 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { It 'Invokes the FileSystem dependency type' { Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force - Should -Invoke Copy-Item -Times 1 -Exactly + Should -Invoke Copy-Item -Times 1 -Exactly -ModuleName PSDepend } It 'Still copies if file hashes do not match' { New-Item -ItemType File -Path (Join-Path $script:SavePath 'notepad.exe') -Force Invoke-PSDepend @Verbose -Path "$TestDepends\filesystem.depend.psd1" -Force - Should -Invoke Copy-Item -Times 1 -Exactly + Should -Invoke Copy-Item -Times 1 -Exactly -ModuleName PSDepend } } @@ -854,20 +854,20 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } It 'Returns $false if file does not exist' { - Mock Copy-Item + Mock Copy-Item -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1" | Test-Dependency @Verbose -Quiet) $Results.count | Should -Be 1 $Results[0] | Should -Be $False - Should -Invoke Copy-Item -Times 0 -Exactly + Should -Invoke Copy-Item -Times 0 -Exactly -ModuleName PSDepend } It 'Returns $true if file does exist' { xcopy C:\Windows\notepad.exe $(Join-Path $script:SavePath '*') /Y - Mock Copy-Item + Mock Copy-Item -ModuleName PSDepend $Results = @( Get-Dependency @Verbose -Path "$TestDepends\filesystem.depend.psd1" | Test-Dependency @Verbose -Quiet) $Results.count | Should -Be 1 $Results[0] | Should -Be $true - Should -Invoke Copy-Item -Times 0 -Exactly + Should -Invoke Copy-Item -Times 0 -Exactly -ModuleName PSDepend } } } @@ -876,12 +876,20 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Get-Package { - [cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) + # Inject stub functions into PSDepend's module scope so Package.ps1 + # (dot-sourced inside the module) resolves these names to stubs instead + # of the real PackageManagement commands, allowing -ModuleName PSDepend mocks to work. + & (Get-Module PSDepend) { + function Get-Package { [cmdletbinding()]param($ProviderName, $Name, $RequiredVersion) } + function Install-Package { [cmdletbinding()]param($Source, $Name, $RequiredVersion, $Force) } + function Find-Package { [cmdletbinding()]param($Name, $Source) } + function Get-PackageSource { } } - function Install-Package { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion) + } + + AfterAll { + & (Get-Module PSDepend) { + Remove-Item Function:\Get-Package, Function:\Install-Package, Function:\Find-Package, Function:\Get-PackageSource -ErrorAction SilentlyContinue } } @@ -915,12 +923,6 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Same package version exists' { BeforeAll { - function Install-Package { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) - } - function Get-PackageSource { - @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) - } Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ @@ -941,12 +943,6 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Latest package required, and already installed' { BeforeAll { - function Install-Package { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) - } - function Get-PackageSource { - @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) - } Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ @@ -970,22 +966,6 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { } Context 'Test-Dependency' { - BeforeAll { - if (-not (Get-Command Get-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { - function Get-Package { - [cmdletbinding()]param( $ProviderName, $Name, $RequiredVersion) Write-Verbose "WTF NOW" - } - } - if (-not (Get-Command Install-Package -Module PackageManagement -ErrorAction SilentlyContinue)) { - function Install-Package { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion, $Force) - } - } - function Get-PackageSource { - @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey' }) - } - } - BeforeEach { Mock Install-Package {} -ModuleName PSDepend Mock Find-Package {} -ModuleName PSDepend @@ -1090,9 +1070,9 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { BeforeAll { Mock Get-NodeModule { return $null } -ModuleName PSDepend Mock Install-NodeModule {} -ModuleName PSDepend - Mock New-Item { return true } - Mock Push-Location - Mock Pop-Location + Mock New-Item { return $true } -ModuleName PSDepend + Mock Push-Location -ModuleName PSDepend + Mock Pop-Location -ModuleName PSDepend $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" $script:Results = Invoke-PSDepend @Verbose -Path "$TestDepends\npm.depend.psd1" -Force @@ -1114,9 +1094,9 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Tests Dependency' { BeforeAll { Mock Install-NodeModule {} -ModuleName PSDepend - Mock New-Item { return true } - Mock Push-Location - Mock Pop-Location + Mock New-Item { return $true } -ModuleName PSDepend + Mock Push-Location -ModuleName PSDepend + Mock Pop-Location -ModuleName PSDepend $script:Dependencies = Get-Dependency @Verbose -Path "$TestDepends\npm.depend.psd1" } From 652864c556996f65b0536bd86bf8df43bd6c4c42 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sat, 2 May 2026 23:35:40 -0700 Subject: [PATCH 18/22] test: fix Package, Npm, and Chocolatey mock failures in Pester v5 - Package: add [cmdletbinding()]param() to Get-PackageSource stub so Pester can generate a valid v5 mock proxy without ParameterBindingException - Package: add Mock Get-PackageSource -ModuleName PSDepend to the three contexts that were hitting the real cmdlet (Same version, Latest, Test-Dependency) - Npm: fix ParameterFilter from { $Target -eq 'Global' } to { $Global -eq $true }; Npm.ps1 calls Get-NodeModule -Global (switch), not -Target 'Global' - Chocolatey 'installs Chocolatey': add -ModuleName PSDepend to Get-Command and Invoke-WebRequest mocks and Should -Invoke assertions - Chocolatey skip/install contexts: replace unmockable inline helpers (Get-ChocoInstalledPackage, Get-ChocoLatestPackage, Invoke-ChocoInstallPackage) with Invoke-ExternalCommand mocks; the inline functions are dot-sourced into local scope and shadow module-scope mocks, but Invoke-ExternalCommand is a PSDepend private module function that Pester can intercept; use ParameterFilter on --local-only (installed), list-no-local-only (latest), and upgrade (install) to distinguish the three call types and return appropriate CSV-formatted data Co-Authored-By: Claude Sonnet 4.6 --- Tests/PSModuleGallery.Type.Tests.ps1 | 76 ++++++++++++---------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 362df6f..49af591 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -883,7 +883,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { function Get-Package { [cmdletbinding()]param($ProviderName, $Name, $RequiredVersion) } function Install-Package { [cmdletbinding()]param($Source, $Name, $RequiredVersion, $Force) } function Find-Package { [cmdletbinding()]param($Name, $Source) } - function Get-PackageSource { } + function Get-PackageSource { [cmdletbinding()]param() } } } @@ -923,6 +923,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Same package version exists' { BeforeAll { + Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } -ModuleName PSDepend Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ @@ -943,6 +944,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Latest package required, and already installed' { BeforeAll { + Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } -ModuleName PSDepend Mock Install-Package -ModuleName PSDepend Mock Get-Package { [pscustomobject]@{ @@ -967,6 +969,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Test-Dependency' { BeforeEach { + Mock Get-PackageSource { @([pscustomobject]@{Name = 'chocolatey'; ProviderName = 'chocolatey'}) } -ModuleName PSDepend Mock Install-Package {} -ModuleName PSDepend Mock Find-Package {} -ModuleName PSDepend } @@ -1111,7 +1114,7 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { 'gitbook-cli' = @{ version = '2.3.0' } - } } -ParameterFilter { $Target -eq 'Global' } -ModuleName PSDepend + } } -ParameterFilter { $Global -eq $true } -ModuleName PSDepend Mock Get-NodeModule { return [pscustomobject]@{ 'gitbook-summary' = @{ version = '1.2.3' @@ -1220,29 +1223,23 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - # So... these didn't work with mocking. Create function, define alias to override any function call, mock that. - function Invoke-ChocoInstallPackage { - [cmdletbinding()]param($Name, $Version, $Source, $Force, $Credential) - } - function Get-ChocoLatestPackage { - [cmdletbinding()]param( $Source, $Name, $RequiredVersion) - } - function Get-ChocoInstalledPackage { - [cmdletbinding()]param($Name) - } + # Simulate choco.exe being present so tests don't hit the install-chocolatey branch by default + Mock Get-Command -ParameterFilter { $Name -eq 'choco.exe' } -MockWith { [pscustomobject]@{Name = 'choco.exe'} } -ModuleName PSDepend + # Default catch-all for Invoke-ExternalCommand; individual tests register specific ParameterFilter mocks + Mock Invoke-ExternalCommand -ModuleName PSDepend } Context 'Chocolatey is not installed' { It 'installs Chocolatey' { - Mock Get-Command -ParameterFilter { $Name -eq 'choco.exe' } -MockWith { return $false } - Mock Invoke-WebRequest + Mock Get-Command -ParameterFilter { $Name -eq 'choco.exe' } -MockWith { return $false } -ModuleName PSDepend + Mock Invoke-WebRequest -ModuleName PSDepend # this will throw as the source is invalid - lets catch that { Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.specificversionrequested.depend.psd1" -Force -ErrorAction Stop } | Should -Throw - Should -Invoke Get-Command -Times 1 -Exactly - Should -Invoke Invoke-WebRequest -Times 1 -Exactly + Should -Invoke Get-Command -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-WebRequest -Times 1 -Exactly -ModuleName PSDepend } } @@ -1256,64 +1253,55 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { Context 'Package version installed is what is requested' { It 'skips installing the package' { - - Mock Get-ChocoInstalledPackage { @{ Name = $Name; Version = '1.0' } } - Mock Get-ChocoLatestPackage - Mock Invoke-ChocoInstallPackage + Mock Invoke-ExternalCommand { "7zip|1.0" } -ParameterFilter { $Arguments -contains '--local-only' } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.specificversionrequested.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly - Should -Invoke Get-ChocoLatestPackage -Times 0 -Exactly - Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments -contains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -Times 0 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'upgrade' } -Times 0 -Exactly -ModuleName PSDepend } } Context 'Package version installed is latest' { It 'skips installing the package' { - - Mock Get-ChocoInstalledPackage { @{ Name = $Name; Version = '2.0' } } - Mock Get-ChocoLatestPackage { @{ Name = $Name; Version = '2.0' } } - Mock Invoke-ChocoInstallPackage + Mock Invoke-ExternalCommand { "7zip|2.0" } -ParameterFilter { $Arguments -contains '--local-only' } -ModuleName PSDepend + Mock Invoke-ExternalCommand { "7zip|2.0" } -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly - Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly - Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments -contains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'upgrade' } -Times 0 -Exactly -ModuleName PSDepend } } Context 'Package requested is latest and version installed is newer than available in source' { It 'skips installing the package' { - - Mock Get-ChocoInstalledPackage { @{ Name = $Name; Version = '2.0' } } - Mock Get-ChocoLatestPackage { @{ Name = $Name; Version = '1.0' } } - Mock Invoke-ChocoInstallPackage + Mock Invoke-ExternalCommand { "7zip|2.0" } -ParameterFilter { $Arguments -contains '--local-only' } -ModuleName PSDepend + Mock Invoke-ExternalCommand { "7zip|1.0" } -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly - Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly - Should -Invoke Invoke-ChocoInstallPackage -Times 0 -Exactly + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments -contains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'upgrade' } -Times 0 -Exactly -ModuleName PSDepend } } Context 'Package requested is latest and version installed is older than available in source' { It 'installs the package' { - - Mock Get-ChocoInstalledPackage { @{ Name = $Name; Version = '1.0' } } - Mock Get-ChocoLatestPackage { @{ Name = $Name; Version = '2.0' } } - Mock Invoke-ChocoInstallPackage + Mock Invoke-ExternalCommand { "7zip|1.0" } -ParameterFilter { $Arguments -contains '--local-only' } -ModuleName PSDepend + Mock Invoke-ExternalCommand { "7zip|2.0" } -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -ModuleName PSDepend Invoke-PSDepend @Verbose -Path "$TestDepends\chocolatey.latestversionrequested.depend.psd1" -Force -ErrorAction Stop - Should -Invoke Get-ChocoInstalledPackage -Times 1 -Exactly - Should -Invoke Get-ChocoLatestPackage -Times 1 -Exactly - Should -Invoke Invoke-ChocoInstallPackage -Times 1 -Exactly + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments -contains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'list' -and $Arguments -notcontains '--local-only' } -Times 1 -Exactly -ModuleName PSDepend + Should -Invoke Invoke-ExternalCommand -ParameterFilter { $Arguments[0] -eq 'upgrade' } -Times 1 -Exactly -ModuleName PSDepend } } } From e8c1c54534cc63cefadf92d87195ecaebe051269 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 3 May 2026 09:36:28 -0700 Subject: [PATCH 19/22] test: use script: scope qualifier on Package stub injection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without the script: scope qualifier, function definitions inside & (Get-Module PSDepend) { function Foo { } } are created in a temporary scope that vanishes when the scriptblock returns. The stubs were never actually shadowing the real cmdlets. Pester's mock proxy was being generated from the real Get-Package / Install-Package / Find-Package / Get-PackageSource cmdlets (from AnyPackage on Linux, PackageManagement elsewhere) — whose multi-parameter -set definitions failed to bind our test splats with ParameterBindingException: Parameter set cannot be resolved. Using function script:Foo persists the stub in the module's script scope so Get-Command -Module PSDepend resolves to the stub, and Pester generates the proxy from the stub's simple param signature. Co-Authored-By: Claude Opus 4.7 --- Tests/PSModuleGallery.Type.Tests.ps1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Tests/PSModuleGallery.Type.Tests.ps1 b/Tests/PSModuleGallery.Type.Tests.ps1 index 49af591..8f9cc67 100644 --- a/Tests/PSModuleGallery.Type.Tests.ps1 +++ b/Tests/PSModuleGallery.Type.Tests.ps1 @@ -876,14 +876,17 @@ Describe "PSModuleGallery Type" -Tag 'Integration' { BeforeAll { $script:SavePath = (New-Item 'TestDrive:/PSDependPesterTest' -ItemType Directory -Force).FullName - # Inject stub functions into PSDepend's module scope so Package.ps1 - # (dot-sourced inside the module) resolves these names to stubs instead - # of the real PackageManagement commands, allowing -ModuleName PSDepend mocks to work. + # Inject stub functions into PSDepend's module scope so Pester generates + # mock proxies from these simple param signatures instead of the real + # PackageManagement/AnyPackage cmdlets (whose multi-parameter-set definitions + # cause ParameterBindingException when called with our test splats). + # NOTE: 'script:' qualifier is required — without it, the function is created + # in a temporary scope that vanishes when the scriptblock returns. & (Get-Module PSDepend) { - function Get-Package { [cmdletbinding()]param($ProviderName, $Name, $RequiredVersion) } - function Install-Package { [cmdletbinding()]param($Source, $Name, $RequiredVersion, $Force) } - function Find-Package { [cmdletbinding()]param($Name, $Source) } - function Get-PackageSource { [cmdletbinding()]param() } + function script:Get-Package { [cmdletbinding()]param($ProviderName, $Name, $RequiredVersion) } + function script:Install-Package { [cmdletbinding()]param($Source, $Name, $RequiredVersion, $Force) } + function script:Find-Package { [cmdletbinding()]param($Name, $Source) } + function script:Get-PackageSource { [cmdletbinding()]param() } } } From 23445bba675e17ad895a74192ac6dccc77c4aff1 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 3 May 2026 09:56:13 -0700 Subject: [PATCH 20/22] Address Copilot suggestions + Docs --- .github/workflows/ci.yml | 9 +- .gitignore | 3 +- .vscode/settings.json | 6 +- PSDepend/PSDepend.psd1 | 142 +++++++++++----------- PSDepend/Private/Get-ClonedObject.ps1 | 29 ++++- PSDepend/Private/Test-PlatformSupport.ps1 | 9 +- PSDepend/Public/Get-Dependency.ps1 | 2 +- PSDepend/en-US/about_PSDepend.help.txt | 2 +- Tests/Help.tests.ps1 | 3 + docs/en-US/Get-Dependency.md | 6 +- docs/en-US/Get-PSDependScript.md | 4 +- docs/en-US/Get-PSDependType.md | 4 +- docs/en-US/Import-Dependency.md | 6 +- docs/en-US/Install-Dependency.md | 8 +- docs/en-US/Invoke-DependencyScript.md | 5 +- docs/en-US/Invoke-PSDepend.md | 13 +- docs/en-US/Test-Dependency.md | 6 +- psakeFile.ps1 | 12 +- 18 files changed, 155 insertions(+), 114 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dbaa9c..03adb2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,4 @@ name: CI -permissions: - checks: write - pull-requests: write - contents: read on: push: branches: [ master ] @@ -25,6 +21,8 @@ jobs: test: name: Test (${{ matrix.os }}) runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: false matrix: @@ -48,6 +46,9 @@ jobs: name: Publish Test Results needs: test runs-on: ubuntu-latest + permissions: + checks: write + pull-requests: write if: ${{ !cancelled() }} steps: - uses: actions/download-artifact@v4 diff --git a/.gitignore b/.gitignore index bf3b0c4..6e28a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ nuget.exe Output/** -Tests/Output/** \ No newline at end of file +Tests/Output/** +Tests/out/** \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 54c8569..67d2203 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,7 @@ "powershell.codeFormatting.ignoreOneLineBlock": false, "powershell.codeFormatting.whitespaceAfterSeparator": false, "powershell.codeFormatting.whitespaceAroundOperator": false, - "powershell.codeFormatting.whitespaceBeforeOpenParen": false -} + "powershell.codeFormatting.whitespaceBeforeOpenParen": false, + "powershell.codeFormatting.preset": "OTBS", + "powershell.codeFormatting.trimWhitespaceAroundPipe": true +} \ No newline at end of file diff --git a/PSDepend/PSDepend.psd1 b/PSDepend/PSDepend.psd1 index 51e044d..c2ce99d 100644 --- a/PSDepend/PSDepend.psd1 +++ b/PSDepend/PSDepend.psd1 @@ -1,111 +1,111 @@ @{ -# Script module or binary module file associated with this manifest. -RootModule = 'PSDepend.psm1' + # Script module or binary module file associated with this manifest. + RootModule = 'PSDepend.psm1' -# Version number of this module. -ModuleVersion = '0.3.0' + # Version number of this module. + ModuleVersion = '0.3.0' -# ID used to uniquely identify this module -GUID = '63ea9e2a-320d-43ff-a11a-4930ca03cce6' + # ID used to uniquely identify this module + GUID = '63ea9e2a-320d-43ff-a11a-4930ca03cce6' -# Author of this module -Author = 'Warren Frame' + # Author of this module + Author = 'Warren Frame' -# Company or vendor of this module -#CompanyName = 'Unknown' + # Company or vendor of this module + #CompanyName = 'Unknown' -# Copyright statement for this module -Copyright = '(c) 2016 Warren F. All rights reserved.' + # Copyright statement for this module + Copyright = '(c) 2016 Warren F. All rights reserved.' -# Description of the functionality provided by this module -Description = 'PowerShell Dependency Handler' + # Description of the functionality provided by this module + Description = 'PowerShell Dependency Handler' -# Minimum version of the Windows PowerShell engine required by this module -PowerShellVersion = '3.0' + # Minimum version of the Windows PowerShell engine required by this module + PowerShellVersion = '3.0' -# Name of the Windows PowerShell host required by this module -# PowerShellHostName = '' + # Name of the Windows PowerShell host required by this module + # PowerShellHostName = '' -# Minimum version of the Windows PowerShell host required by this module -# PowerShellHostVersion = '' + # Minimum version of the Windows PowerShell host required by this module + # PowerShellHostVersion = '' -# Minimum version of Microsoft .NET Framework required by this module -# DotNetFrameworkVersion = '' + # Minimum version of Microsoft .NET Framework required by this module + # DotNetFrameworkVersion = '' -# Minimum version of the common language runtime (CLR) required by this module -# CLRVersion = '' + # Minimum version of the common language runtime (CLR) required by this module + # CLRVersion = '' -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' + # Processor architecture (None, X86, Amd64) required by this module + # ProcessorArchitecture = '' -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() + # Modules that must be imported into the global environment prior to importing this module + # RequiredModules = @() -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() + # Assemblies that must be loaded prior to importing this module + # RequiredAssemblies = @() -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() + # Script files (.ps1) that are run in the caller's environment prior to importing this module. + # ScriptsToProcess = @() -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() + # Type files (.ps1xml) to be loaded when importing this module + # TypesToProcess = @() -# Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = 'PSDepend.Format.ps1xml' + # Format files (.ps1xml) to be loaded when importing this module + FormatsToProcess = 'PSDepend.Format.ps1xml' -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() + # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess + # NestedModules = @() -# Functions to export from this module -FunctionsToExport = @('Get-Dependency','Get-PSDependScript','Get-PSDependType','Import-Dependency','Install-Dependency','Invoke-DependencyScript','Invoke-PSDepend','Test-Dependency') + # Functions to export from this module + FunctionsToExport = @('Get-Dependency','Get-PSDependScript','Get-PSDependType','Import-Dependency','Install-Dependency','Invoke-DependencyScript','Invoke-PSDepend','Test-Dependency') -# Cmdlets to export from this module -CmdletsToExport = '*' + # Cmdlets to export from this module + CmdletsToExport = '*' -# Variables to export from this module -# VariablesToExport = '*' + # Variables to export from this module + # VariablesToExport = '*' -# Aliases to export from this module -AliasesToExport = '*' + # Aliases to export from this module + AliasesToExport = '*' -# DSC resources to export from this module -# DscResourcesToExport = @() + # DSC resources to export from this module + # DscResourcesToExport = @() -# List of all modules packaged with this module -# ModuleList = @() + # List of all modules packaged with this module + # ModuleList = @() -# List of all files packaged with this module -# FileList = @() + # List of all files packaged with this module + # FileList = @() -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ + # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. + PrivateData = @{ - PSData = @{ + PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('requirements', 'dependencies', 'dependency', 'manager', 'bundle', 'package') + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('requirements', 'dependencies', 'dependency', 'manager', 'bundle', 'package') - # A URL to the license for this module. - LicenseUri = 'https://github.com/RamblingCookieMonster/PSDepend/blob/master/LICENSE' + # A URL to the license for this module. + LicenseUri = 'https://github.com/PowerShellOr/PSDepend/blob/master/LICENSE' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/RamblingCookieMonster/PSDepend/' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/PowerShellOr/PSDepend/' - # A URL to an icon representing this module. - # IconUri = '' + # A URL to an icon representing this module. + # IconUri = '' - # ReleaseNotes of this module - ReleaseNotes = 'Added various PowerShell Core fixes thanks to @lipkau!' + # ReleaseNotes of this module + ReleaseNotes = 'Added various PowerShell Core fixes thanks to @lipkau!' - } # End of PSData hashtable + } # End of PSData hashtable -} # End of PrivateData hashtable + } # End of PrivateData hashtable -# HelpInfo URI of this module -# HelpInfoURI = '' + # HelpInfo URI of this module + # HelpInfoURI = '' -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' + # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. + # DefaultCommandPrefix = '' } diff --git a/PSDepend/Private/Get-ClonedObject.ps1 b/PSDepend/Private/Get-ClonedObject.ps1 index 8594ebd..502cd2b 100644 --- a/PSDepend/Private/Get-ClonedObject.ps1 +++ b/PSDepend/Private/Get-ClonedObject.ps1 @@ -1,8 +1,31 @@ -# Idea from http://stackoverflow.com/questions/7468707/deep-copy-a-dictionary-hashtable-in-powershell -# borrowed from http://stackoverflow.com/questions/8982782/does-anyone-have-a-dependency-graph-and-topological-sorting-code-snippet-for-pow function Get-ClonedObject { + <# + .SYNOPSIS + Clones + + .DESCRIPTION + Creates a deep copy of the provided object. This is useful for cloning + dependency objects before passing them to dependency scripts, allowing + modifications to the clone without affecting the original object. + + .PARAMETER DeepCopyObject + The source object to copy from. + + .EXAMPLE + Get-ClonedObject $MyObject + + Get a deep copy of $MyObject. This is used to clone dependency objects + before passing them to dependency scripts, so that we can modify the object + without affecting the original. + + .NOTES + Idea from https://stackoverflow.com/a/7475744 + borrowed from https://stackoverflow.com/q/8982782 + + BinaryFormatter was removed in .NET 7; use a recursive hashtable clone + instead + #> param($DeepCopyObject) - # BinaryFormatter was removed in .NET 7; use a recursive hashtable clone instead $clone = @{} foreach ($key in $DeepCopyObject.Keys) { $val = $DeepCopyObject[$key] diff --git a/PSDepend/Private/Test-PlatformSupport.ps1 b/PSDepend/Private/Test-PlatformSupport.ps1 index 6a0c9d2..34eec5e 100644 --- a/PSDepend/Private/Test-PlatformSupport.ps1 +++ b/PSDepend/Private/Test-PlatformSupport.ps1 @@ -1,8 +1,9 @@ function Test-PlatformSupport { - [cmdletbinding()] + [CmdletBinding()] param( $Type, - [string[]]$Support + [string[]] + $Support ) # test core/full @@ -14,8 +15,8 @@ Write-Verbose "Supported platforms [$Support] for type [$Type] does not contain [core]. Pull requests welcome!" return $false } - } - else { # full windows powershell + } else { + # full windows powershell if($Support -notcontains 'windows') { Write-Verbose "Supported platforms [$Support] for type [$Type] does not contain [windows]. Pull requests welcome!" return $false diff --git a/PSDepend/Public/Get-Dependency.ps1 b/PSDepend/Public/Get-Dependency.ps1 index d8913af..f9784db 100644 --- a/PSDepend/Public/Get-Dependency.ps1 +++ b/PSDepend/Public/Get-Dependency.ps1 @@ -385,7 +385,7 @@ function Get-Dependency { } } - # Heleper to retrieve the credential for a dependency + # Helper to retrieve the credential for a dependency function Resolve-Credential { [CmdletBinding()] param ( diff --git a/PSDepend/en-US/about_PSDepend.help.txt b/PSDepend/en-US/about_PSDepend.help.txt index b5fdc13..0c8d27b 100644 --- a/PSDepend/en-US/about_PSDepend.help.txt +++ b/PSDepend/en-US/about_PSDepend.help.txt @@ -159,4 +159,4 @@ DETAILED DESCRIPTION SEE ALSO about_PSDepend_Definitions - https://github.com/RamblingCookieMonster/PSDepend \ No newline at end of file + https://github.com/PowerShellOr/PSDepend \ No newline at end of file diff --git a/Tests/Help.tests.ps1 b/Tests/Help.tests.ps1 index 9b71829..8eca696 100644 --- a/Tests/Help.tests.ps1 +++ b/Tests/Help.tests.ps1 @@ -1,6 +1,9 @@ # Taken with love from @juneb_get_help (https://raw.githubusercontent.com/juneb/PesterTDD/master/Module.Help.Tests.ps1) BeforeDiscovery { + if ($null -eq $env:BHPSModuleManifest) { + & "$PSScriptRoot/../Build.ps1" -Task Init + } function global:FilterOutCommonParams { param ($Params) $commonParameters = [System.Management.Automation.PSCmdlet]::CommonParameters + diff --git a/docs/en-US/Get-Dependency.md b/docs/en-US/Get-Dependency.md index 6a06fa6..4354e7f 100644 --- a/docs/en-US/Get-Dependency.md +++ b/docs/en-US/Get-Dependency.md @@ -14,12 +14,14 @@ Read a dependency psd1 file. ## SYNTAX ### File (Default) + ``` Get-Dependency [-Path ] [-Tags ] [-Recurse] [-Credentials ] [-ProgressAction ] [] ``` ### Hashtable + ``` Get-Dependency [-Tags ] [-InputObject ] [-Credentials ] [-ProgressAction ] [] @@ -130,6 +132,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -145,6 +148,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -158,5 +162,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Invoke-PSDepend](Invoke-PSDepend.md) diff --git a/docs/en-US/Get-PSDependScript.md b/docs/en-US/Get-PSDependScript.md index cc25e32..aa8a8b7 100644 --- a/docs/en-US/Get-PSDependScript.md +++ b/docs/en-US/Get-PSDependScript.md @@ -50,6 +50,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -65,6 +66,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -74,5 +76,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-PSDependType](Get-PSDependType.md) diff --git a/docs/en-US/Get-PSDependType.md b/docs/en-US/Get-PSDependType.md index d2395df..8cb6db8 100644 --- a/docs/en-US/Get-PSDependType.md +++ b/docs/en-US/Get-PSDependType.md @@ -108,6 +108,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -123,6 +124,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -132,5 +134,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-PSDependScript](Get-PSDependScript.md) diff --git a/docs/en-US/Import-Dependency.md b/docs/en-US/Import-Dependency.md index 63a8552..d7d766b 100644 --- a/docs/en-US/Import-Dependency.md +++ b/docs/en-US/Import-Dependency.md @@ -84,6 +84,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -99,6 +100,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -110,7 +112,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-Dependency](Get-Dependency.md) -[Install-Dependency](Install-Dependency.md) -[Invoke-PSDepend](Invoke-PSDepend.md) diff --git a/docs/en-US/Install-Dependency.md b/docs/en-US/Install-Dependency.md index 188b60c..1c41f03 100644 --- a/docs/en-US/Install-Dependency.md +++ b/docs/en-US/Install-Dependency.md @@ -108,6 +108,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml @@ -123,6 +124,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -138,6 +140,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -153,6 +156,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -164,7 +168,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-Dependency](Get-Dependency.md) -[Import-Dependency](Import-Dependency.md) -[Invoke-PSDepend](Invoke-PSDepend.md) diff --git a/docs/en-US/Invoke-DependencyScript.md b/docs/en-US/Invoke-DependencyScript.md index 00d8c2a..7f2c23a 100644 --- a/docs/en-US/Invoke-DependencyScript.md +++ b/docs/en-US/Invoke-DependencyScript.md @@ -116,6 +116,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -131,6 +132,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -142,6 +144,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-Dependency](Get-Dependency.md) -[Invoke-PSDepend](Invoke-PSDepend.md) diff --git a/docs/en-US/Invoke-PSDepend.md b/docs/en-US/Invoke-PSDepend.md index 9569f52..f64b019 100644 --- a/docs/en-US/Invoke-PSDepend.md +++ b/docs/en-US/Invoke-PSDepend.md @@ -14,6 +14,7 @@ Install, import, or test dependencies defined in a PSDepend file. ## SYNTAX ### installimport-file (Default) + ``` Invoke-PSDepend [[-Path] ] [-PSDependTypePath ] [-Tags ] [-Recurse ] [-Import] [-Install] [-Force] [-Target ] [-Credentials ] @@ -21,6 +22,7 @@ Invoke-PSDepend [[-Path] ] [-PSDependTypePath ] [-Tags ] [-PSDependTypePath ] [-Tags ] [-Recurse ] [-Test] [-Quiet] [-Force] [-Target ] [-ProgressAction ] [-WhatIf] [-Confirm] @@ -28,12 +30,14 @@ Invoke-PSDepend [[-Path] ] [-PSDependTypePath ] [-Tags ] [-PSDependTypePath ] [-Tags ] [-Test] [-Quiet] [-Force] [-Target ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### installimport-hashtable + ``` Invoke-PSDepend [[-InputObject] ] [-PSDependTypePath ] [-Tags ] [-Import] [-Install] [-Force] [-Target ] [-Credentials ] [-ProgressAction ] @@ -277,6 +281,7 @@ Accept wildcard characters: False ``` ### -WhatIf + Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml @@ -292,6 +297,7 @@ Accept wildcard characters: False ``` ### -Confirm + Prompts you for confirmation before running the cmdlet. ```yaml @@ -307,6 +313,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -322,6 +329,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -333,8 +341,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-Dependency](Get-Dependency.md) -[Install-Dependency](Install-Dependency.md) -[Import-Dependency](Import-Dependency.md) -[Test-Dependency](Test-Dependency.md) diff --git a/docs/en-US/Test-Dependency.md b/docs/en-US/Test-Dependency.md index a0dd9d3..19d62f4 100644 --- a/docs/en-US/Test-Dependency.md +++ b/docs/en-US/Test-Dependency.md @@ -108,6 +108,7 @@ Accept wildcard characters: False ``` ### -ProgressAction + {{ Fill ProgressAction Description }} ```yaml @@ -123,6 +124,7 @@ Accept wildcard characters: False ``` ### CommonParameters + This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). ## INPUTS @@ -134,7 +136,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ## NOTES ## RELATED LINKS - -[Get-Dependency](Get-Dependency.md) -[Install-Dependency](Install-Dependency.md) -[Invoke-PSDepend](Invoke-PSDepend.md) diff --git a/psakeFile.ps1 b/psakeFile.ps1 index 353e1e3..1547744 100644 --- a/psakeFile.ps1 +++ b/psakeFile.ps1 @@ -9,7 +9,8 @@ Properties { $PSBPreference.Build.CopyDirectories = @('PSDependScripts', 'en-US') # Test configuration - $PSBPreference.Test.OutputFile = './Output/testResults.xml' + $PSBPreference.Help.DefaultLocale = 'en-US' + $PSBPreference.Test.OutputFile = 'out/testResults.xml' $PSBPreference.Test.OutputFormat = 'JUnitXml' $PSBPreference.Test.ScriptAnalysis.Enabled = $true $PSBPreference.Test.ScriptAnalysis.FailBuildOnSeverityLevel = 'Error' @@ -30,4 +31,13 @@ $PSBBuildDependency = @('StageFiles') Task Default -Depends Test +# PowerShellBuild adds the following tasks: +# - Init +# - Clean +# - StageFiles +# - Build +# - Test +# - BuildHelp +# - GenerateMarkdown +# - Publish Task Test -FromModule PowerShellBuild -MinimumVersion '0.7.3' From 638b553e23aaf9aeb8b3fc581522ba3a6e57f4c4 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 3 May 2026 10:00:04 -0700 Subject: [PATCH 21/22] =?UTF-8?q?fix(ci):=20=F0=9F=90=9B=20correct=20path?= =?UTF-8?q?=20for=20test=20results=20upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated the path for uploading test results from `./Output/testResults.xml` to `./Tests/out/testResults.xml` to ensure proper artifact handling. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03adb2c..61c03d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,7 +40,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: testResults-${{ matrix.os }} - path: ./Output/testResults.xml + path: ./Tests/out/testResults.xml publish-test-results: name: Publish Test Results From 2fcfaa4cc95cec7ffe6dc90ae447e89913ededbb Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Sun, 3 May 2026 11:08:43 -0700 Subject: [PATCH 22/22] =?UTF-8?q?fix:=20=F0=9F=90=9B=20update=20URLs=20to?= =?UTF-8?q?=20correct=20organization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed LicenseUri and ProjectUri in `PSDepend.psd1` and `about_PSDepend.help.txt` to point to the correct GitHub organization. --- PSDepend/PSDepend.psd1 | 4 ++-- PSDepend/en-US/about_PSDepend.help.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PSDepend/PSDepend.psd1 b/PSDepend/PSDepend.psd1 index c2ce99d..6e1f918 100644 --- a/PSDepend/PSDepend.psd1 +++ b/PSDepend/PSDepend.psd1 @@ -87,10 +87,10 @@ Tags = @('requirements', 'dependencies', 'dependency', 'manager', 'bundle', 'package') # A URL to the license for this module. - LicenseUri = 'https://github.com/PowerShellOr/PSDepend/blob/master/LICENSE' + LicenseUri = 'https://github.com/PowerShellOrg/PSDepend/blob/master/LICENSE' # A URL to the main website for this project. - ProjectUri = 'https://github.com/PowerShellOr/PSDepend/' + ProjectUri = 'https://github.com/PowerShellOrg/PSDepend/' # A URL to an icon representing this module. # IconUri = '' diff --git a/PSDepend/en-US/about_PSDepend.help.txt b/PSDepend/en-US/about_PSDepend.help.txt index 0c8d27b..3a493b4 100644 --- a/PSDepend/en-US/about_PSDepend.help.txt +++ b/PSDepend/en-US/about_PSDepend.help.txt @@ -159,4 +159,4 @@ DETAILED DESCRIPTION SEE ALSO about_PSDepend_Definitions - https://github.com/PowerShellOr/PSDepend \ No newline at end of file + https://github.com/PowerShellOrg/PSDepend \ No newline at end of file