65 lines
3.0 KiB
PowerShell
65 lines
3.0 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 = ""
|
|
|
|
#region Get-ServicesToStart
|
|
|
|
Describe "Get-ServicesToStart" {
|
|
|
|
Mock -ModuleName $moduleForMock Get-AlkamiServices { return @(
|
|
@{ Status = "Running"; Name = "Subscriptions"; DisplayName = "Subscriptions Service"},
|
|
@{ Status = "Running"; Name = "Alkami.MicroServices.Broker.Host"; DisplayName = "Alkami.MicroServices.Broker.Host"},
|
|
@{ Status = "Running"; Name = "Alkami Nag Service"; DisplayName = "Alkami Nag Service"},
|
|
@{ Status = "Stopped"; Name = "Alkami.Stopped.Service"; DisplayName = "Alkami Stopped Service"}
|
|
@{ Status = "Stopped"; Name = "Alkami.Stopped.Legacy.Service"; DisplayName = "Alkami Stopped Service"}
|
|
) }
|
|
|
|
Mock -ModuleName $moduleForMock Get-ChocolateyServices { return @(
|
|
@{ State = "Running"; Name = "Alkami.Services.Subscriptions.Host"; PathName = "`"C:\`" -displayname `"Alkami.Services.Subscriptions.Host`" -servicename `"Alkami.Services.Subscriptions.Host" },
|
|
@{ State = "Running"; Name = "Alkami.MicroServices.Contacts.Service.Host"; PathName = "`"C:\`" -displayname `"Alkami.Services.Contacts.Service.Host`" -servicename `"Alkami.Services.Contacts.Service.Host" },
|
|
@{ State = "Running"; Name = "Alkami.MicroServices.SiteText.Service.Host"; PathName = "`"C:\`" -displayname `"Alkami.Services.SiteText.Service.Host`" -servicename `"Alkami.Services.SiteText.Service.Host" },
|
|
@{ State = "Stopped"; Name = "Alkami.Stopped.Service"; DisplayName = "Alkami Stopped Service"},
|
|
@{ State = "Stopped"; Name = "Alkami.Stopped.Chocolatey.Service"; PathName = "`"C:\`" -displayname `"Alkami.Stopped.Service`" -servicename `"Alkami.Stopped.Service" }
|
|
) }
|
|
|
|
Context "Switch Validations" {
|
|
|
|
It "Should skip AlkamiServices When switch Set" {
|
|
|
|
Get-ServicesToStart -skipAlkamiServices
|
|
Assert-MockCalled -ModuleName $moduleForMock Get-AlkamiServices -Times 0 -Exactly -Scope It
|
|
}
|
|
|
|
It "Should skip chocolatey service when switch set" {
|
|
|
|
Get-ServicesToStart -skipChocolateyServices
|
|
Assert-MockCalled -ModuleName $moduleForMock Get-ChocolateyServices -Times 0 -Exactly -Scope It
|
|
}
|
|
|
|
It "Should not return services that are already started" {
|
|
|
|
$result = Get-ServicesToStart
|
|
$result.Count | Should -Be 3
|
|
}
|
|
|
|
It "Returns Only Unique Service Names" {
|
|
|
|
Mock -ModuleName $moduleForMock Get-AlkamiServices { return @(
|
|
@{ Status = "Stopped"; Name = "Alkami.Duplicate.Service"; DisplayName = "Alkami Duplicate Service"}
|
|
) }
|
|
|
|
Mock -ModuleName $moduleForMock Get-ChocolateyServices { return @(
|
|
@{ State = "Stopped"; Name = "Alkami.Duplicate.Service"; DisplayName = "Alkami Duplicate Service"}
|
|
) }
|
|
|
|
$result = Get-ServicesToStart
|
|
$result.Count | Should -Be 1
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Get-ServicesToStart |