. $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 "Test-AlkamiManifest" {
function New-FakeServiceManifest {
$sampleManifest = @"
1.0
Alkami
Alkami.MicroServices.Testing.FakeService
Service
DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF
framework
Alkami.MicroServices.Testing.FakeService
my_service_role
"@
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
Set-Content -Path $testFile -value $sampleManifest
}
function New-FakeServiceManifestWithReleaseManagement {
$sampleManifest = @"
1.0
Alkami
Alkami.MicroServices.Testing.FakeService
Service
DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF
true
framework
Alkami.MicroServices.Testing.FakeService
my_service_role
"@
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
Set-Content -Path $testFile -value $sampleManifest
}
function New-InvalidServiceManifestWithReleaseManagement {
$sampleManifest = @"
1.0
Alkami
Alkami.MicroServices.Testing.FakeService
Service
DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF
not_a_bool
framework
Alkami.MicroServices.Testing.FakeService
my_service_role
"@
$testFile = "TestDrive:\NewServiceAlkamiManifest.xml"
Set-Content -Path $testFile -value $sampleManifest
}
function New-ValidFluentMigrationManifest {
$sampleManifest = @"
1.0
Alkami
Alkami.Migrations.UserReporting.Migrations
FluentMigration
framework
1.4.0
tenant
MSSQL
Alkami.Migrations.UserReporting.Migrations.dll
Alkami.Migrations.UserReporting_Service
"@
$testFile = "TestDrive:\NewFluentMigrationAlkamiManifest.xml"
Set-Content -Path $testFile -value $sampleManifest
}
Mock -ModuleName $moduleForMock -CommandName Get-LogLeadName -MockWith { return "SUT" }
Mock -ModuleName $moduleForMock -CommandName Write-Verbose -MockWith { }
Mock -ModuleName $moduleForMock -CommandName Write-Host -MockWith { }
Mock -ModuleName $moduleForMock -CommandName Get-AlkamiManifestFilename -MockWith { return "NewServiceAlkamiManifest.xml" }
# The expectation is that we will have multiple versions here. We might need more contexts per version at that point.
Context "When Testing a Service Manifest" {
New-FakeServiceManifest
Mock -ModuleName $moduleForMock -CommandName Test-AlkamiServiceManifest10 -MockWith { return @{ success = $true } }
It "Calls Test-AlkamiServiceManifest10" {
Test-AlkamiManifest -Source "TestDrive:\NewServiceAlkamiManifest.xml"
Assert-MockCalled -CommandName Test-AlkamiServiceManifest10 -Scope It
}
}
Context "When Testing a Service Manifest with Release Management" {
New-FakeServiceManifestWithReleaseManagement
It "Returns true" {
Test-AlkamiManifest -Source "TestDrive:\NewServiceAlkamiManifest.xml" | Should -BeTrue
}
}
Context "When Testing a FluentMigration manifest" {
Mock -ModuleName $moduleForMock -CommandName Get-AlkamiManifestFilename -MockWith { return "NewFluentMigrationAlkamiManifest.xml" }
New-ValidFluentMigrationManifest
It "Returns true" {
Test-AlkamiManifest -Source "TestDrive:\NewFluentMigrationAlkamiManifest.xml" | Should -BeTrue
}
}
Context "When Testing an invalid Service Manifest with Release Management" {
New-InvalidServiceManifestWithReleaseManagement
It "Returns false" {
Test-AlkamiManifest -Source "TestDrive:\NewServiceAlkamiManifest.xml" | Should -BeFalse
}
}
}