@@ -2,11 +2,26 @@ BeforeAll {
22 $repoRoot = Split-Path - Parent (Split-Path - Parent $PSCommandPath )
33 $moduleDir = Join-Path $repoRoot " PowerShellDevToolkit"
44 Import-Module $moduleDir - Force
5+
6+ $configPath = Join-Path $repoRoot " config.json"
7+ $examplePath = Join-Path $repoRoot " config.example.json"
8+ $script :hadConfig = Test-Path $configPath
9+ if (-not $script :hadConfig -and (Test-Path $examplePath )) {
10+ Copy-Item $examplePath $configPath
11+ $script :createdConfig = $true
12+ }
13+ }
14+
15+ AfterAll {
16+ if ($script :createdConfig ) {
17+ $configPath = Join-Path $repoRoot " config.json"
18+ Remove-Item $configPath - ErrorAction SilentlyContinue
19+ }
520}
621
722Describe " Get-ServiceStatus" {
823 It " Should return JSON array with expected fields for git" {
9- $raw = powershell - NoProfile - ExecutionPolicy Bypass - Command " Import-Module '$moduleDir ' -Force; Get-ServiceStatus git -AsJson"
24+ $raw = pwsh - NoProfile - Command " Import-Module '$moduleDir ' -Force -DisableNameChecking ; Get-ServiceStatus git -AsJson"
1025 $result = $raw | ConvertFrom-Json
1126 ($result | Measure-Object ).Count | Should - BeGreaterThan 0
1227 $first = $result [0 ]
@@ -16,22 +31,22 @@ Describe "Get-ServiceStatus" {
1631 }
1732
1833 It " Should report git as available" {
19- $raw = powershell - NoProfile - ExecutionPolicy Bypass - Command " Import-Module '$moduleDir ' -Force; Get-ServiceStatus git -AsJson"
34+ $raw = pwsh - NoProfile - Command " Import-Module '$moduleDir ' -Force -DisableNameChecking ; Get-ServiceStatus git -AsJson"
2035 $result = $raw | ConvertFrom-Json
2136 $git = $result | Where-Object { $_.id -eq ' git' }
2237 $git | Should -Not - BeNullOrEmpty
2338 $git.status | Should - Be ' running'
2439 }
2540
2641 It " Should handle unknown service name" {
27- $raw = powershell - NoProfile - ExecutionPolicy Bypass - Command " Import-Module '$moduleDir ' -Force; Get-ServiceStatus nonexistent_xyz -AsJson"
42+ $raw = pwsh - NoProfile - Command " Import-Module '$moduleDir ' -Force -DisableNameChecking ; Get-ServiceStatus nonexistent_xyz -AsJson"
2843 $result = $raw | ConvertFrom-Json
2944 $svc = $result | Where-Object { $_.id -eq ' nonexistent_xyz' }
3045 $svc.status | Should - Be ' unknown'
3146 }
3247
3348 It " Should filter to only requested services" {
34- $raw = powershell - NoProfile - ExecutionPolicy Bypass - Command " Import-Module '$moduleDir ' -Force; Get-ServiceStatus git node -AsJson"
49+ $raw = pwsh - NoProfile - Command " Import-Module '$moduleDir ' -Force -DisableNameChecking ; Get-ServiceStatus git node -AsJson"
3550 $result = $raw | ConvertFrom-Json
3651 ($result | Measure-Object ).Count | Should - Be 2
3752 $ids = $result | ForEach-Object { $_.id }
0 commit comments