Public/Set-PsModuleBuilderPath.tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.' . "$here\$sut" Describe Set-PsModuleBuilderPath { # mock $env:PsModulePath # C:\Users\username\OneDrive\Documents\WindowsPowerShell\Modules; # C:\Program Files\WindowsPowerShell\Modules; # C:\Windows\system32\WindowsPowerShell\v1.0\Modules Context "When path provided is container..." { $expected = "TestDrive:\Modules" New-Item $expected -ItemType Directory -Force | Out-Null Set-PsModuleBuilderPath $expected It "Should set the module builder path to the path provided" { Import-CliXml -Path "$PsScriptRoot\..\Data\psmodulebuilderpath.xml" | Should -Be $expected } } Context "When path provided is not container..." { It "Should throw an error" { { Set-PsModuleBuilderPath "Not a real path" } | Should -Throw } } Context "When setting default path..." { Set-PsModuleBuilderPath -Default $expected = (Get-UserPsModulePath) It "Should set the module builder path to the default user modules path" { Import-CliXml -Path "$PsScriptRoot\..\Data\psmodulebuilderpath.xml" | Should -Be $expected } } Context "Housekeeping..." { It "Accepts -Path parameter" { Get-Command Set-PsModuleBuilderPath | Should -HaveParameter Path Get-Command Set-PsModuleBuilderPath | Should -HaveParameter Path -Not -Mandatory } It "Accepts -Default parameter" { Get-Command Set-PsModuleBuilderPath | Should -HaveParameter ShouldUseDefault Get-Command Set-PsModuleBuilderPath | Should -HaveParameter ShouldUseDefault -Not -Mandatory } } } |