Skip to content

Commit

Permalink
test: git@ repos
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Nov 27, 2023
1 parent dcc2284 commit ee0c9cc
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions updater/tests/nonbot-commits.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,34 @@ Set-StrictMode -Version latest

. "$PSScriptRoot/common/test-utils.ps1"

function NonBotCommits([Parameter(Mandatory = $true)][string] $branch)
foreach ($repoUrl in @('https://github.com/getsentry/github-workflows', '[email protected]:getsentry/github-workflows.git'))
{
$result = & "$PSScriptRoot/../scripts/nonbot-commits.ps1" `
-RepoUrl 'https://github.com/getsentry/github-workflows' -MainBranch 'main' -PrBranch $branch
if (-not $?)
function NonBotCommits([Parameter(Mandatory = $true)][string] $branch)
{
throw $result
$result = & "$PSScriptRoot/../scripts/nonbot-commits.ps1" -RepoUrl $repoUrl -MainBranch 'main' -PrBranch $branch
if (-not $?)
{
throw $result
}
elseif ($LASTEXITCODE -ne 0)
{
throw "Script finished with exit code $LASTEXITCODE"
}
$result
}
elseif ($LASTEXITCODE -ne 0)
{
throw "Script finished with exit code $LASTEXITCODE"
}
$result
}

RunTest 'empty-if-all-commits-by-bot' {
$commits = NonBotCommits 'deps/updater/tests/sentry-cli.properties'
AssertEqual '' "$commits"
}
RunTest 'empty-if-all-commits-by-bot' {
$commits = NonBotCommits 'deps/updater/tests/sentry-cli.properties'
AssertEqual '' "$commits"
}

RunTest 'empty-if-branch-doesnt-exist' {
$commits = NonBotCommits 'non-existent-branch'
AssertEqual '' "$commits"
}
RunTest 'empty-if-branch-doesnt-exist' {
$commits = NonBotCommits 'non-existent-branch'
AssertEqual '' "$commits"
}

RunTest 'non-empty-if-changed' {
$commits = NonBotCommits 'test/nonbot-commits'
AssertEqual '0b7d9cc test: keep this branch' "$commits"
}
RunTest 'non-empty-if-changed' {
$commits = NonBotCommits 'test/nonbot-commits'
AssertEqual '0b7d9cc test: keep this branch' "$commits"
}
}

0 comments on commit ee0c9cc

Please sign in to comment.