From c1bc2c12bb2963e3d05d49e931fc8cd43b0f9002 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Mon, 27 Nov 2023 22:12:08 +0000 Subject: [PATCH] Add test for `-GamePlatform`, `-GameEngine` and `-Game` --- Generate-GitBranches.Tests.ps1 | 39 ++++++++++++++++++++++++++++++++++ Generate-GitBranches.ps1 | 10 +++++++++ 2 files changed, 49 insertions(+) diff --git a/Generate-GitBranches.Tests.ps1 b/Generate-GitBranches.Tests.ps1 index b057ef2f..24fde215 100644 --- a/Generate-GitBranches.Tests.ps1 +++ b/Generate-GitBranches.Tests.ps1 @@ -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' { @@ -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' + ) + } + } + } } diff --git a/Generate-GitBranches.ps1 b/Generate-GitBranches.ps1 index 24ff8f25..3d2099eb 100644 --- a/Generate-GitBranches.ps1 +++ b/Generate-GitBranches.ps1 @@ -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