From dde3fad4d8a6f4823d88158568fc7f86cd14f146 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 6 Mar 2018 08:32:01 +0100 Subject: [PATCH] #130 Fix semver v2 related failing tests --- AU/Private/AUVersion.ps1 | 2 ++ tests/Get-Version.Tests.ps1 | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/AU/Private/AUVersion.ps1 b/AU/Private/AUVersion.ps1 index 8e5587c2..ac240c09 100644 --- a/AU/Private/AUVersion.ps1 +++ b/AU/Private/AUVersion.ps1 @@ -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('.', '') } # diff --git a/tests/Get-Version.Tests.ps1 b/tests/Get-Version.Tests.ps1 index c99f677b..487d64ff 100644 --- a/tests/Get-Version.Tests.ps1 +++ b/tests/Get-Version.Tests.ps1 @@ -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 = @(