ps/Modules/Alkami.PowerShell.Common/Public/Get-SupportedPlatformAPMVersionMap.tests.ps1

52 lines
2.4 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
. $PSScriptRoot\..\..\Load-PesterModules.ps1
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.'
$functionPath = Join-Path -Path $here -ChildPath $sut
Write-Host "Overriding SUT: $functionPath"
Import-Module $functionPath -Force
$moduleForMock = ""
############################
# These Are Not Unit Tests #
############################
# These just attempt to ensure nobody accidentally mangles the hashtable array returned by the function
# which would result in hilarity, but also a bunch of bad things too
Describe "Get-SupportedPlatformAPMVersionMap" {
Context "Poor Life Choices" {
It "Has One and Only One Element With a Null PlatformMaximumVersion" {
# Did this test fail? You accidentally have no elements or more than 1 elements in the APM <-> Platform Version Map with a Null Max Value.
#
# There can be only one.
# - Connor MacLeod
$nullMaxVersions = Get-SupportedPlatformAPMVersionMap | Where-Object { $null -eq $_.PlatformMaximumVersion }
([hashtable[]]$nullMaxVersions).Count | Should -Be 1
}
It "Only Has One Element With a 0.0.0 PlatformMinimumVersion" {
# Did this test fail? You accidentally have no elements or more than 1 elements in the APM <-> Platform Version Map with a Min Value Equivilant to 0
#
# One is the lonliest number that you'll ever do
# - Three Dog Night
$zeroMinVersions = Get-SupportedPlatformAPMVersionMap | Where-Object { ("0.0.0" -eq $_.PlatformMinimumVersion) -or ("0.0.0.0" -eq $_.PlatformMinimumVersion) }
([hashtable[]]$zeroMinVersions).Count | Should -Be 1
}
It "Doesn't Have Any Duplicate APM Version Entries" {
# Did this test fail? You accidentally have more than one element with the same APM version. That shouldn't be needed. Discuss with the author if you think I'm wrong!
#
# You cannot duplicate this, you can't do me, I'm complicated
# -Lil Nacho
$map = Get-SupportedPlatformAPMVersionMap
$groupedValues = $map | ForEach-Object { $_.APMVersion } | Group-Object
$groupedValues | Where-Object {$_.Count -gt 1} | Select-Object -ExpandProperty Name | Should -BeNullOrEmpty
}
}
}