Tests/Write-PsmManifest.Tests.ps1
$moduleRoot = Resolve-Path "$PSScriptRoot\.." $moduleName = Split-Path $moduleRoot -Leaf Import-Module "$moduleRoot\PSModuleBuilder.psm1" Describe "Write-PsmManifest" -Tag "Unit" { Context 'When in an initialized module folder' { BeforeAll { Write-Verbose "Creating new directory PsmManifest" Remove-ItemIfExists "$PSScriptRoot\TestPester\PsmManifest" | Out-Null New-Item "$PSScriptRoot\TestPester\PsmManifest" -ItemType Directory -Force Write-Verbose "Changing location to PsmManifest" Set-Location "$PSScriptRoot\TestPester\PsmManifest" Initialize-Psm -y Get-ChildItem "$PSScriptRoot\TestPester\PsmManifest" } Context "When module exists" { InModuleScope PSModuleBuilder { $Psd1 = Import-CliXml .\module-psd1.xml $Psd1.Path = "$($Psd1.ModuleName).psd1" $emptyArray = @() Write-PsmManifest it "should have a package xml file" { "$PSScriptRoot\TestPester\PsmManifest\module-psd1.xml" | Should -Exist } it "should write manifest.psd1 file" { $Psd1.Path | Should -Exist } it "should add a module to packagexml.RequiredModules -- > 0 Check" { {Test-ModuleManifest $Psd1.Path -ErrorAction Stop -WarningAction SilentlyContinue} | Should -Not -Throw } } } } Context 'When in a non-initialized module folder' { BeforeAll { Set-Location "$PSScriptRoot\TestPester" } InModuleScope PSModuleBuilder { it "should throw due to missing package folders/files" { { Write-PsmManifest } | Should -Throw } } } AfterAll { Write-Host "Changing back to moduleRoot: $PSScriptRoot" Set-Location $PSScriptRoot } } |