Skip to content

Commit

Permalink
fix MacOS test (I hope)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Nov 27, 2024
1 parent 6f817e6 commit 10a272d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions tests/integration/Service.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Describe 'Service Lifecycle' {

it 'register' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Register
Start-Sleep 10
Start-Sleep 2
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
if ($IsMacOS) {
$status.Status | Should -Be 'Running'
Expand All @@ -26,7 +26,7 @@ Describe 'Service Lifecycle' {

it 'start' -Skip:( $IsMacOS) {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Start
Start-Sleep 10
Start-Sleep 2
$webRequest = Invoke-WebRequest -uri http://localhost:8080 -ErrorAction SilentlyContinue
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
$status.Status | Should -Be 'Running'
Expand All @@ -37,7 +37,7 @@ Describe 'Service Lifecycle' {

it 'pause' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Suspend
Start-Sleep 10
Start-Sleep 2
# $webRequest = Invoke-WebRequest -uri http://localhost:8080 -ErrorAction SilentlyContinue
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
$status.Status | Should -Be 'Suspended'
Expand All @@ -48,7 +48,7 @@ Describe 'Service Lifecycle' {

it 'resume' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -resume
Start-Sleep 10
Start-Sleep 2
$webRequest = Invoke-WebRequest -uri http://localhost:8080 -ErrorAction SilentlyContinue
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
$status.Status | Should -Be 'Running'
Expand All @@ -58,7 +58,7 @@ Describe 'Service Lifecycle' {
}
it 'stop' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Stop
Start-Sleep 10
Start-Sleep 2
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
$status.Status | Should -Be 'Stopped'
$status.Name | Should -Be 'Hello Service'
Expand All @@ -69,7 +69,7 @@ Describe 'Service Lifecycle' {

it 're-start' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Start
Start-Sleep 10
Start-Sleep 2
$webRequest = Invoke-WebRequest -uri http://localhost:8080 -ErrorAction SilentlyContinue
$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
$status.Status | Should -Be 'Running'
Expand All @@ -81,7 +81,7 @@ Describe 'Service Lifecycle' {

it 're-stop' {
. "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Stop
Start-Sleep 10
Start-Sleep 2


$status = . "$($PSScriptRoot)\..\..\examples\HelloService\HelloService.ps1" -Query
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/Service.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Describe 'Start-PodeService' {
}

It 'Starts a started service ' -Skip:(!$IsLinux) {

Mock -CommandName Start-PodeLinuxService -MockWith { $true }
Mock -CommandName Get-PodeServiceStatus -MockWith {
[pscustomobject]@{ Name = 'TestService'; Status = 'Running' }
Expand All @@ -206,19 +206,19 @@ Describe 'Start-PodeService' {

Context 'On macOS platform' {
It 'Starts a stopped service successfully' -Skip:(!$IsMacOS) {
Mock -CommandName Test-PodeMacOsServiceIsRegistered -MockWith { $true }
Mock -CommandName Start-PodeMacOsService -MockWith { $true }

$script:status = $null
Mock -CommandName Test-PodeMacOsServiceIsActive -MockWith {
if ($null -eq $script:status ) {
$script:status = $false
$script:status = 'none'
Mock -CommandName Get-PodeServiceStatus -MockWith {
if ($script:status -eq 'none') {
$script:status = 'Stopped'
}
else {
$script:status = $true
$script:status = 'Running'
}
return $script:status
[pscustomobject]@{ Name = 'TestService'; Status = $status }
}
Mock -CommandName Wait-PodeServiceStatus { $true }
Mock -CommandName Test-PodeMacOsServiceIsRegistered -MockWith { $true }
Mock -CommandName Start-PodeMacOsService -MockWith { $true }

# Act
Start-PodeService -Name 'MacService' | Should -Be $true
Expand Down

0 comments on commit 10a272d

Please sign in to comment.