Skip to content

Commit

Permalink
Added failing test for issue #19
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Nov 13, 2018
1 parent 0b07266 commit 915bde1
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/public/Get-FixVersion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Describe 'Get-FixVersion' {
$rootPath = $PSScriptRoot
sc -Value "" -Path "$rootPath\test.nuspec"

Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
#Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
$nuspecFile = "$PSScriptRoot/../private/ValidNuspec.nuspec"
It "Should return same version when no padding is needed" {
$global:au_Force = $false
Expand All @@ -30,6 +30,7 @@ Describe 'Get-FixVersion' {
}

It "Throws exception when the passed version is invalid" {
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
{ Get-FixVersion -Version '0' } | Should Throw
{ Get-FixVersion -Version '0.5.23.2.1' } | Should Throw
{ Get-FixVersion -Version '0.54-preview-beta-ueaj' } | Should Throw
Expand Down Expand Up @@ -65,6 +66,7 @@ Describe 'Get-FixVersion' {

It "Returns padded version but no fix if version is higher than previous" {
$global:au_Force = $false
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "0.1.0" } } -Verifiable -ModuleName "Wormies-AU-Helpers"

Get-FixVersion -Version 0.5.3.2 -NuspecFile $nuspecFile | Should Be "0.5.3.200"
Expand All @@ -73,6 +75,7 @@ Describe 'Get-FixVersion' {
It "Returns padded version when one is used in nuspec file, and no force is used" {
$global:au_Force = $false

Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "0.5.3.200" } } -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version 0.5.3.2 -NuspecFile $nuspecFile | Should Be "0.5.3.200"
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "0.5.3.201" } } -ModuleName "Wormies-AU-Helpers"
Expand All @@ -84,6 +87,7 @@ Describe 'Get-FixVersion' {
It "Returns padded fix version when one is used in the nuspec file, and force is used" {
$global:au_Force = $true

Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "0.5.3.200" } } -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version 0.5.3.2 -NuspecFile $nuspecFile | Should Be "0.5.3.201"
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "0.5.3.201" } } -ModuleName "Wormies-AU-Helpers"
Expand All @@ -94,7 +98,36 @@ Describe 'Get-FixVersion' {

It "Should return padded fix version when onlyFixBelowVersion is higher than current and force is used" {
$global:au_Force = $true
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = "myid"; version = "10.5.16.49299" }} -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version "10.5.16.49299" -NuspecFile $nuspecFile -OnlyFixBelowVersion "10.5.17" | Should Be "10.5.16.4929901"
}

It "Should return previous fix version even when OnlyFixBelow is lower" {
$global:au_Force = $false
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = 'myid'; version = '70.0.3538.10200' }} -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version "70.0.3538.102" -NuspecFile $nuspecFile -OnlyFixBelowVersion '57.0.2988' | Should Be '70.0.3538.10200'
}

It "Should return previous fix version for pre-releases even when OnlyFixBelow is lower" {
$global:au_Force = $false
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = 'myid'; version = '70.0.3538-beta1-20181113' }} -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version "70.0.3538-beta1" -NuspecFile $nuspecFile -OnlyFixBelowVersion '57.0.2988' | Should Be '70.0.3538-beta1-20181113'
}

It "Should return previous fix version even when OnlyFixBelow is equal" {
$global:au_Force = $false
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = 'myid'; version = '70.0.3538.10200' }} -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version "70.0.3538.102" -NuspecFile $nuspecFile -OnlyFixBelowVersion '70.0.3538.102' | Should Be '70.0.3538.10200'
}

It "Should return previous fix version for pre-releases even when OnlyFixBelow is lower" {
$global:au_Force = $false
Mock "Resolve-Path" { return "$rootPath\test.nuspec" }
Mock Get-NuspecMetadata { return @{ id = 'myid'; version = '70.0.3538-beta1-20181113' }} -ModuleName "Wormies-AU-Helpers"
Get-FixVersion -Version "70.0.3538-beta1" -NuspecFile $nuspecFile -OnlyFixBelowVersion '70.0.3538-beta1' | Should Be '70.0.3538-beta1-20181113'
}
}

0 comments on commit 915bde1

Please sign in to comment.