Skip to content

Commit

Permalink
majkinetor#130 Fix semver v2 related failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas committed Mar 6, 2018
1 parent 7333d6f commit dde3fad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions AU/Private/AUVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class AUVersion : System.IComparable {
if ($pr -and !$strict) { $pr = $pr.Replace(' ', '.') }
if ($bm -and !$strict) { $bm = $bm.Replace(' ', '.') }
# for now, chocolatey does only support SemVer v1 (no dot separated identifiers in pre-release):
if ($pr -and $strict -and $pr -like '*.*') { return $false }
if ($bm -and $strict -and $bm -like '*.*') { return $false }
if ($pr) { $pr = $pr.Replace('.', '') }
if ($bm) { $bm = $bm.Replace('.', '') }
#
Expand Down
11 changes: 5 additions & 6 deletions tests/Get-Version.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ Describe 'Get-Version' -Tag getversion {
}

$testCases = @(
@{Value = '1.2-beta.3' ; ExpectedResult = '1.2-beta3'}
@{Value = '1.2+xyz.4' ; ExpectedResult = '1.2+xyz4'}
@{Value = '1.2-beta.3+xyz.4' ; ExpectedResult = '1.2-beta3+xyz4'}
@{Value = '1.2-beta.3'}
@{Value = '1.2+xyz.4'}
@{Value = '1.2-beta.3+xyz.4'}
)

It 'converts semver v2 to semver v1' -TestCases $testCases { param($Value, $ExpectedResult)
$version = [AUVersion] $Value
$version | Should Be ([AUVersion] $ExpectedResult)
It 'does not convert semver v2' -TestCases $testCases { param($Value, $ExpectedResult)
{ [AUVersion] $Value } | Should Throw 'Invalid version'
}

$testCases = @(
Expand Down

0 comments on commit dde3fad

Please sign in to comment.