ps/Modules/Alkami.DevOps.SqlReports/Public/Publish-SqlReports.Tests.ps1

80 lines
3.3 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 = ""
describe -Tag 'Unit' 'Publish-SqlReports' {
it "should not call publish-ssrsreportsdirectory if test-iswebserver == false." {
mock -ModuleName $moduleForMock publish-ssrsreportsdirectory -mockwith { }
mock -ModuleName $moduleForMock test-path -verifiable { return $true }
mock -ModuleName $moduleForMock test-iswebserver -mockwith { return $false }
Publish-SqlReports -reportFolder "aws test 6"
Assert-MockCalled -ModuleName $moduleForMock Publish-SSRSReportsDirectory 0
}
it "should not call publish-ssrsreportsdirectory if the reportfoldernode is null or empty" {
# report server path is null
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return "JunkUrl"
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServer" }
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return $null
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServerPath" }
mock -ModuleName $moduleForMock publish-ssrsreportsdirectory -mockwith {}
mock -ModuleName $moduleForMock test-iswebserver -mockwith { return $true }
mock -ModuleName $moduleForMock Test-Path -Verifiable { return $true }
Publish-SqlReports -reportFolder "aws test 6"
assert-mockcalled -ModuleName $moduleForMock publish-ssrsreportsdirectory 0
}
it "should not call publish-ssrsreportsdirectory if the reportserverendpointnode is null or empty" {
# report server url is null
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return $null
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServer" }
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return "c:\junkPath"
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServerPath" }
mock -ModuleName $moduleForMock publish-ssrsreportsdirectory -mockwith {}
mock -ModuleName $moduleForMock test-iswebserver -mockwith { return $true }
Publish-SqlReports -reportFolder "aws test 6"
assert-mockcalled -ModuleName $moduleForMock publish-ssrsreportsdirectory 0
}
it "should call Publish-SSRSReportsDirectory" {
# Full config
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return "JunkUrl"
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServer" }
mock -ModuleName $moduleForMock Get-AppSetting -MockWith {
return "c:\junkPath"
} -ParameterFilter { $appSettingKey -and $appSettingKey -eq "ReportServerPath" }
mock -ModuleName $moduleForMock Publish-SSRSReportsDirectory -MockWith {}
mock -ModuleName $moduleForMock Test-IsWebserver -MockWith { return $true }
mock -ModuleName $moduleForMock Test-Path -Verifiable { return $true }
Publish-SqlReports -ReportFolder "AWS Test 6"
Assert-MockCalled -ModuleName $moduleForMock Publish-SSRSReportsDirectory
}
}