-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test if curent user is admin * Refactor Pester tests * refactor & pester tests * typo * add end of line
- Loading branch information
Showing
5 changed files
with
115 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Describe 'Install-SteamCMD Tests' -Tag 'Integration' { | ||
BeforeAll { | ||
. "$($SteamPSModulePath)\Private\Server\Add-EnvPath.ps1" | ||
Add-EnvPath -Path 'TestDrive:\Test\SteamCMD' | ||
} | ||
|
||
Context 'When executing Install-SteamCMD' { | ||
It 'Should install SteamCMD' { | ||
Install-SteamCMD -InstallPath 'TestDrive:\Test' -Force | ||
} | ||
|
||
It 'Should find steamcmd.exe' { | ||
Test-Path -Path "$TestDrive\Test\SteamCMD\steamcmd.exe" | Should -BeTrue | ||
} | ||
} | ||
|
||
AfterAll { | ||
# Wait for the process steamerrorreporter to be closed - else test folder wont be deleted. | ||
Wait-Process -Name 'steamerrorreporter' -ErrorAction SilentlyContinue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
Describe 'Update-SteamApp Tests' -Tag 'Integration' { | ||
BeforeAll { | ||
. "$($SteamPSModulePath)\Private\Server\Add-EnvPath.ps1" | ||
Add-EnvPath -Path 'TestDrive:\Test\SteamCMD' | ||
|
||
if ((Test-Path -Path "$TestDrive\Test\SteamCMD\steamcmd.exe") -eq $false) { | ||
Install-SteamCMD -InstallPath 'TestDrive:\Test' -Force | ||
} | ||
} | ||
|
||
Context 'When executing Update-SteamApp' { | ||
It 'Installs Ground Branch Dedicated Server using AppID' { | ||
Update-SteamApp -AppID 476400 -Path "$TestDrive\GB-AppID" -Force | ||
Test-Path -Path "$TestDrive\GB-AppID\GroundBranchServer.exe" | Should -BeTrue | ||
} | ||
|
||
It 'Installs Ground Branch Dedicated Server using Application Name' { | ||
Update-SteamApp -ApplicationName 'Ground Branch D' -Path "$TestDrive\GB-AppName" -Force | ||
Test-Path -Path "$TestDrive\GB-AppName\GroundBranchServer.exe" | Should -BeTrue | ||
} | ||
|
||
It 'Passes custom argument and installs testing branch of Ground Branch Dedicated Server' { | ||
Update-SteamApp -AppID 476400 -Path "$TestDrive\GB-TestingBranch" -Arguments "-beta testing" -Force | ||
Test-Path -Path "$TestDrive\GB-TestingBranch\GroundBranchServer.exe" | Should -BeTrue | ||
} | ||
} | ||
|
||
AfterAll { | ||
# Wait for the process steamerrorreporter to be closed - else test folder wont be deleted. | ||
Wait-Process -Name 'steamerrorreporter' -ErrorAction SilentlyContinue | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
Describe 'Update-SteamServer Tests' -Tag 'Unit' { | ||
Context 'When executing Update-SteamServer without SteamCMD installed' { | ||
BeforeAll { | ||
Mock -CommandName Test-Admin -ModuleName SteamPS -MockWith { | ||
return $true | ||
} | ||
Mock -CommandName Get-SteamPath -ModuleName SteamPS -MockWith { | ||
return $null | ||
} | ||
Mock -CommandName Get-Service -ModuleName SteamPS -MockWith { | ||
return @{ Name = 'GB-PG10' } | ||
} | ||
} | ||
It 'Should throw an error' { | ||
{ Update-SteamServer -AppID 476400 -ServiceName 'GB-PG10' -IPAddress '1.1.1.1' -Port 27015 } | Should -Throw 'SteamCMD could not be found in the env:Path. Have you executed Install-SteamCMD?' | ||
} | ||
} | ||
|
||
Context 'When executing Update-SteamServer with insufficient permissions' { | ||
BeforeAll { | ||
Mock -CommandName Test-Admin -ModuleName SteamPS -MockWith { | ||
return $false | ||
} | ||
Mock -CommandName Get-SteamPath -ModuleName SteamPS -MockWith { | ||
return [PSCustomObject]@{ | ||
'Path' = 'C:\Program Files\' | ||
'Executable' = 'C:\Program Files\steamcmd.exe' | ||
} | ||
} | ||
Mock -CommandName Get-Service -ModuleName SteamPS -MockWith { | ||
return @{ Name = 'GB-PG10' } | ||
} | ||
} | ||
It 'Should throw an error' { | ||
{ Update-SteamServer -AppID 476400 -ServiceName 'GB-PG10' -IPAddress '1.1.1.1' -Port 27015 } | Should -Throw 'The current PowerShell session is not running as Administrator. Start PowerShell by using the Run as Administrator option, and then try running the script again.' | ||
} | ||
} | ||
} |