-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from pspete/feature-VersionCompare
Feature version compare
- Loading branch information
Showing
70 changed files
with
1,128 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#Get Current Directory | ||
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
|
||
#Get Function Name | ||
$FunctionName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1" | ||
|
||
#Assume ModuleName from Repo Root folder | ||
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf | ||
|
||
#Resolve Path to Module Directory | ||
$ModulePath = Resolve-Path "$Here\..\$ModuleName" | ||
|
||
#Define Path to Module Manifest | ||
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" | ||
|
||
if( -not (Get-Module -Name $ModuleName -All)) { | ||
|
||
Import-Module -Name "$ManifestPath" -Force -ErrorAction Stop | ||
|
||
} | ||
|
||
Describe $FunctionName { | ||
|
||
InModuleScope $ModuleName { | ||
|
||
Context 'Minimum Version Met' { | ||
|
||
It 'returns nothing if version requirment is satisfied' { | ||
Assert-VersionRequirement -ExternalVersion "0.2" -RequiredVersion "0.1" | Should BeNullOrEmpty | ||
} | ||
|
||
It 'does not throw if version requirment is satisfied' { | ||
{Assert-VersionRequirement -ExternalVersion "0.2" -RequiredVersion "0.1"} | Should Not Throw | ||
} | ||
|
||
} | ||
|
||
Context 'Version Check Skipped' { | ||
|
||
It 'returns nothing if external version is "0.0"' { | ||
Assert-VersionRequirement -ExternalVersion "0.0" -RequiredVersion "9.9" | Should BeNullOrEmpty | ||
} | ||
|
||
It 'does not throw if external version is "0.0"' { | ||
{Assert-VersionRequirement -ExternalVersion "0.0" -RequiredVersion "1.1"} | Should Not Throw | ||
} | ||
|
||
} | ||
|
||
Context 'Minimum Version Not Met' { | ||
|
||
Mock Get-ParentFunction -MockWith { | ||
[PSCustomObject]@{ | ||
FunctionName = "SomeFunction" | ||
ParameterSetName = "SomeParameterSet" | ||
} | ||
} | ||
Function Test-Failure {Assert-VersionRequirement -ExternalVersion "1.1" -RequiredVersion "2.0"} | ||
|
||
It 'throws error if external version is less than required version' { | ||
{Test-Failure} | should Throw | ||
} | ||
|
||
It 'throws expected error if no custom parameterset has been used in the parent function' { | ||
|
||
Mock Get-ParentFunction -MockWith { | ||
[PSCustomObject]@{ | ||
FunctionName = "Test-Example" | ||
ParameterSetName = "__AllParameterSets" | ||
} | ||
} | ||
|
||
{Test-Failure} | should Throw "CyberArk 1.1 does not meet the minimum version requirement of 2.0 for Test-Example (using ParameterSet: __AllParameterSets)" | ||
} | ||
|
||
It 'throws expected error if a custom parameterset has been used in the parent function' { | ||
Mock Get-ParentFunction -MockWith { | ||
[PSCustomObject]@{ | ||
FunctionName = "Test-Example" | ||
ParameterSetName = "SomeParamSet" | ||
} | ||
} | ||
{Test-Failure} | should Throw "CyberArk 1.1 does not meet the minimum version requirement of 2.0 for Test-Example (using ParameterSet: SomeParamSet)" | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#Get Current Directory | ||
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
|
||
#Get Function Name | ||
$FunctionName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1" | ||
|
||
#Assume ModuleName from Repo Root folder | ||
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf | ||
|
||
#Resolve Path to Module Directory | ||
$ModulePath = Resolve-Path "$Here\..\$ModuleName" | ||
|
||
#Define Path to Module Manifest | ||
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" | ||
|
||
if( -not (Get-Module -Name $ModuleName -All)) { | ||
|
||
Import-Module -Name "$ManifestPath" -Force -ErrorAction Stop | ||
|
||
} | ||
|
||
Describe $FunctionName { | ||
|
||
InModuleScope $ModuleName { | ||
|
||
It 'returns TRUE if version is greater than minimum version' { | ||
Compare-MinimumVersion -Version "9.8.0" -MinimumVersion "8.9.0" | Should Be $true | ||
} | ||
|
||
It 'returns FALSE if version is less than minimum version' { | ||
Compare-MinimumVersion -Version "9.8.0" -MinimumVersion "9.9.0" | Should Be $false | ||
} | ||
|
||
It 'returns TRUE if version is 0.0' { | ||
|
||
Compare-MinimumVersion -Version "0.0" -MinimumVersion "1.1.0" | Should Be $true | ||
|
||
} | ||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#Get Current Directory | ||
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
|
||
#Get Function Name | ||
$FunctionName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1" | ||
|
||
#Assume ModuleName from Repo Root folder | ||
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf | ||
|
||
#Resolve Path to Module Directory | ||
$ModulePath = Resolve-Path "$Here\..\$ModuleName" | ||
|
||
#Define Path to Module Manifest | ||
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" | ||
|
||
if( -not (Get-Module -Name $ModuleName -All)) { | ||
|
||
Import-Module -Name "$ManifestPath" -Force -ErrorAction Stop | ||
|
||
} | ||
|
||
Describe $FunctionName { | ||
|
||
InModuleScope $ModuleName { | ||
|
||
It 'returns parent function name' { | ||
Function Test-Parent {Test-Child} | ||
Function Test-Child {Get-ParentFunction} | ||
$ThisTest = Test-Parent | ||
|
||
$ThisTest.FunctionName | Should Be Test-Parent | ||
} | ||
|
||
It 'returns expected parent function name from expected scope' { | ||
Function Test-Example { | ||
[CmdletBinding()] | ||
param([parameter(ParameterSetName = "ExampleParamSet")][string]$Name) | ||
Test-Parent | ||
} | ||
Function Test-Parent {Test-Child} | ||
Function Test-Child {Get-ParentFunction -Scope 3} | ||
$ThisTest = Test-Example -Name "test" | ||
|
||
$ThisTest.FunctionName | Should Be "Test-Example" | ||
|
||
} | ||
|
||
It 'returns expected ParameterSetName from expected scope' { | ||
Function Test-Example { | ||
[CmdletBinding()] | ||
param([parameter(ParameterSetName = "ExampleParamSet")][string]$Name) | ||
Test-Parent | ||
} | ||
Function Test-Parent {Test-Child} | ||
Function Test-Child {Get-ParentFunction -Scope 3} | ||
$ThisTest = Test-Example -Name "test" | ||
|
||
$ThisTest.ParameterSetName | Should Be "ExampleParamSet" | ||
} | ||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.