Pester.Tests.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path $manifestPath = "$here\Pester.psd1" $changellogPath = "$here\CHANGELOG.md" Describe "Pester manifest and changelog" { $script:manifest = $null It "has a valid manifest" { { $script:manifest = Test-ModuleManifest -Path $manifestPath -ErrorAction Stop -WarningAction SilentlyContinue } | Should Not Throw } It "has a valid name in the manifest" { $script:manifest.Name | Should Be Pester } It "has a valid guid in the manifest" { $script:manifest.Guid | Should Be 'a699dea5-2c73-4616-a270-1f7abb777e71' } It "has a valid version in the manifest" { $script:manifest.Version -as [Version] | Should Not BeNullOrEmpty } $script:changelogVersion = $null It "has a valid version in the changelog" { foreach ($line in (Get-Content $changellogPath)) { if ($line -match "^\D*(?<Version>(\d+\.){1,3}\d+)") { $script:changelogVersion = $matches.Version break } } $script:changelogVersion | Should Not BeNullOrEmpty $script:changelogVersion -as [Version] | Should Not BeNullOrEmpty } It "changelog and manifest versions are the same" { $script:changelogVersion -as [Version] | Should be ( $script:manifest.Version -as [Version] ) } if (Get-Command git.exe -ErrorAction SilentlyContinue ) { $script:tagVersion It "is tagged with a valid version" { $script:tagVersion = git describe --abbrev=0 --tags $script:tagVersion | Should Not BeNullOrEmpty $script:tagVersion -as [Version] | Should Not BeNullOrEmpty } It "all versions are the same" { $script:changelogVersion -as [Version] | Should be ( $script:manifest.Version -as [Version] ) $script:manifest.Version -as [Version] | Should be ( $script:tagVersion -as [Version] ) } } } if ($PSVersionTable.PSVersion.Major -ge 3) { $error.Clear() Describe 'Clean treatment of the $error variable' { Context 'A Context' { It 'Performs a successful test' { $true | Should Be $true } } It 'Did not add anything to the $error variable' { $error.Count | Should Be 0 } } } |