ps/Modules/Alkami.PowerShell.Configuration/Public/Get-PackageManifest.tests.ps1
2023-05-30 22:51:22 -07:00

55 lines
2.2 KiB
PowerShell

. $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 = ""
Describe "Get-PackageManifest" {
Context "Assembly and Package is provided in Manifest" {
Mock -CommandName Write-Warning -MockWith {}
Mock -CommandName Test-AlkamiManifest -MockWith { $false }
$sampleManifest = @"
<?xml version="1.0"?>
<packageManifest>
<version>1.0</version>
<general>
<creatorCode>Alkami</creatorCode>
<element>Alkami.MicroServices.FluxManagement.Service.Host</element>
<componentType>Service</componentType>
</general>
<serviceManifest>
<runtime>framework</runtime>
<entryPoint>Alkami.MicroServices.FluxManagement.Service.Host</entryPoint>
<!-- Populating the migrations or db_role values will assume the microservice needs connectivity to a tenant database. -->
<migrations>
<assembly target="TENANT" online="false" role="FluxManagement_Service">Alkami.MicroServices.FluxManagement.Migrations.dll</assembly>
<package id="Alkami.MicroServices.FluxManagement.Migrations" version="1.2.0" />
</migrations>
<db_role>FluxManagement_Service</db_role>
</serviceManifest>
</packageManifest>
"@
$FeedSource = "FakeFeed"
$Name = "FakeApp"
$Version = "1.23"
It "Should Throw" {
{ Get-PackageManifest -RawContent $sampleManifest -PackageName $Name -ManifestSource "$FeedSource $Name $Version" } | Should Throw
}
It "Manifest warning equals fake values" {
{ Get-PackageManifest -RawContent $sampleManifest -PackageName $Name -ManifestSource "$FeedSource $Name $Version" } | Should Throw
Assert-MockCalled -CommandName Write-Warning -Times 1 -Exactly -Scope It -ModuleName $moduleForMock -ParameterFilter { $Message -eq
"[Get-PackageManifest] : Manifest at [FakeFeed FakeApp 1.23] failed processing. Please resolve errors and reprocess." }
}
}
}