Skip to content

Commit

Permalink
Add test for -GamePlatform, -GameEngine and -Game
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Nov 27, 2023
1 parent c29ffff commit c1bc2c1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Generate-GitBranches.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,25 @@ Describe "Generate-GitBranches.ps1" {
}
}

It "Creates and updates branches of a same repo of (one game)" {
& $sourceRepo/Generate-GitBranches.ps1 -Repo . -GamePlatform steam -GameEngine hlds -Game valve -ErrorAction Stop 6>$null # Create
& $sourceRepo/Generate-GitBranches.ps1 -Repo . -GamePlatform steam -GameEngine hlds -Game valve -ErrorAction Stop 6>$null # Update

cd $sameRepo
$branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' }
$branches.Count | Should -Be 1
foreach ($b in $branches) {
git ls-tree -r --name-only $b | Should -Be @(
'.env'
'.gitlab-ci.yml'
'.state'
'build.sh'
'build/Dockerfile'
'notify.sh'
'update/Dockerfile'
)
}
}
}

Context 'Different repo' {
Expand Down Expand Up @@ -117,6 +136,26 @@ Describe "Generate-GitBranches.ps1" {
}
}

It "Creates and updates branches of a different repo (one game)" {
& $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -GamePlatform steam -GameEngine hlds -Game valve -ErrorAction Stop 6>$null # Create
& $sourceRepo/Generate-GitBranches.ps1 -Repo $differentRepo -GamePlatform steam -GameEngine hlds -Game valve -ErrorAction Stop 6>$null # Update

cd $differentRepo
$branches = git branch | % { $_.Replace('*', '').Trim() } | ? { $_ -match '^steam-' }
$branches.Count | Should -Be 1
foreach ($b in $branches) {
git ls-tree -r --name-only $b | Should -Be @(
'.env'
'.gitlab-ci.yml'
'.state'
'build.sh'
'build/Dockerfile'
'notify.sh'
'update/Dockerfile'
)
}
}

}

}
10 changes: 10 additions & 0 deletions Generate-GitBranches.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@
# ./Generate-GitBranches.ps1 -Repo . -Pull
#
# # Create branches for specific game
# ./Generate-GitBranches.ps1 -Repo . -Pull -GameEngine hlds -Game valve
# ./Generate-GitBranches.ps1 -Repo . -Pull -GameEngine srcds -Game csgo
#
# # Create branches for specific game(s)
# ./Generate-GitBranches.ps1 -Repo . -Pull -GameEngine hlds -Game valve,cstrike
# ./Generate-GitBranches.ps1 -Repo . -Pull -GameEngine srcds -Game cs2,csgo
#
# # Update branches for all games
# ./Generate-GitBranches.ps1 -Repo . -Pull -Push
#
# # Update branches for specific game
# ./Generate-GitBranches.ps1 -Repo . -Pull -Push -GameEngine hlds -Game valve
# ./Generate-GitBranches.ps1 -Repo . -Pull -Push -GameEngine srcds -Game csgo
#
# # Update branches for specific game(s)
# ./Generate-GitBranches.ps1 -Repo . -Pull -Push -GameEngine hlds -Game valve,cstrike
# ./Generate-GitBranches.ps1 -Repo . -Pull -Push -GameEngine srcds -Game cs2,csgo
#
[CmdletBinding(SupportsShouldProcess)]
param(
# Target repo path
Expand Down

0 comments on commit c1bc2c1

Please sign in to comment.