Tests/HaloAPI.Meta.Tests.ps1
<#
.SYNOPSIS Meta test suite for the HaloAPI module. #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Test file - parameters are used in separate scopes.')] param() BeforeAll { $ModulePath = Split-Path -Parent -Path (Split-Path -Parent -Path $PSCommandPath) $ModuleName = 'HaloAPI' $ManifestPath = "$($ModulePath)\$($ModuleName).psd1" if (Get-Module -Name $ModuleName) { Remove-Module $ModuleName -Force } Import-Module $ManifestPath -Verbose:$False $Script:ModuleInformation = Import-Module -Name $ManifestPath -PassThru } # Test that the manifest is generally correct. Not a functional test. Describe 'Meta' { It 'Manifest is valid' { { Test-ModuleManifest -Path $ManifestPath -ErrorAction Stop -WarningAction SilentlyContinue } | Should -Not -Throw } It 'Root module is correct' { $Script:ModuleInformation.RootModule | Should -Be ".\$($ModuleName).psm1" } It 'Has a description' { $Script:ModuleInformation.Description | Should -Not -BeNullOrEmpty } It 'GUID is correct' { $Script:ModuleInformation.GUID | Should -Be '8bc83215-4735-4029-9f40-e05fe3e8f73b' } It 'Version is valid' { $Script:ModuleInformation.Version -As [Version] | Should -Not -BeNullOrEmpty } It 'Copyright is present' { $Script:ModuleInformation.Copyright | Should -Not -BeNullOrEmpty } It 'License URI is correct' { $Script:ModuleInformation.LicenseUri | Should -Be 'https://mit.license.homotechsual.dev/' } It 'Project URI is correct' { $Script:ModuleInformation.ProjectUri | Should -Be 'https://github.com/homotechsual/HaloAPI' } It 'PowerShell Gallery tags is not empty' { $Script:ModuleInformation.Tags.count | Should -Not -BeNullOrEmpty } It 'PowerShell Gallery tags do not contain spaces' { foreach ($Tag in $Script:ModuleInformation.Tags) { $Tag -NotMatch '\s' | Should -Be $True } } } Describe 'Module HaloAPI loads' { It 'Passed Module load' { Get-Module -Name 'HaloAPI' | Should -Not -Be $null } } |