Skip to content

Commit

Permalink
Fix ReleaseBanches E2E test (microsoft#938)
Browse files Browse the repository at this point in the history
- Change updateVersion value to +1 in E2E tests
- Always set build and revision numbers to 0
  • Loading branch information
mazhelez committed Feb 19, 2024
1 parent 968c76e commit fac74ec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Actions/IncrementVersionNumber/IncrementVersionNumber.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ function Set-VersionInSettingsFile {

# Include build and revision numbers if they exist in the old version number
if ($oldValue -and ($oldValue.Build -ne -1)) {
$versionNumbers += $oldValue.Build
$versionNumbers += 0 # Always set the build number to 0
if ($oldValue.Revision -ne -1) {
$versionNumbers += $oldValue.Revision
$versionNumbers += 0 # Always set the revision number to 0
}
}

Expand Down
22 changes: 22 additions & 0 deletions Tests/IncrementVersionNumber.Action.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,28 @@ Describe "Set-VersionInSettingsFile tests" {
$newSettingsContent.otherSetting | Should -Be "otherSettingValue"
}

It 'Set-VersionInSettingsFile -newValue +0.1 makes build and revision 0 if they are initially set' {
$settingsFile = New-TestSettingsFilePath -repoVersion '1.2.3.4'
$settingName = 'repoVersion'
$newValue = '+0.1'

Set-VersionInSettingsFile -settingsFilePath $settingsFile -settingName $settingName -newValue $newValue

$newSettingsContent = Get-Content $settingsFile -Encoding UTF8 | ConvertFrom-Json
$newSettingsContent.$settingName | Should -Be "1.3.0.0"
}

It 'Set-VersionInSettingsFile -newValue +1 makes build and revision 0 if they are initially set' {
$settingsFile = New-TestSettingsFilePath -repoVersion '1.2.3.4'
$settingName = 'repoVersion'
$newValue = '+1'

Set-VersionInSettingsFile -settingsFilePath $settingsFile -settingName $settingName -newValue $newValue

$newSettingsContent = Get-Content $settingsFile -Encoding UTF8 | ConvertFrom-Json
$newSettingsContent.$settingName | Should -Be "2.0.0.0"
}

AfterEach {
Remove-Item $settingsFile -Force -ErrorAction Ignore
}
Expand Down
2 changes: 1 addition & 1 deletion e2eTests/scenarios/ReleaseBranches/runtest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Test-LogContainsFromRun -runid $run.id -jobName 'Build . (Default) . (Default)'
$tag1 = '1.0.0'
$ver1 = 'v1.0'
$releaseBranch1 = "release/1.0"
$release1 = RunCreateRelease -repository $repository -branch $branch -appVersion 'latest' -name $ver1 -tag $tag1 -createReleaseBranch -updateVersionNumber '+1.0' -directCommit -wait
$release1 = RunCreateRelease -repository $repository -branch $branch -appVersion 'latest' -name $ver1 -tag $tag1 -createReleaseBranch -updateVersionNumber '+1' -directCommit -wait

Test-LogContainsFromRun -runid $release1.id -jobName 'CreateRelease' -stepName 'Prepare release notes' -expectedText "releaseNotes=**Full Changelog**: https://github.com/$repository/commits/$tag1"

Expand Down

0 comments on commit fac74ec

Please sign in to comment.