-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When runing Convert-Path powershell will not consolidate the last '/' if the Path has it, so it may be the same path but the Assert will fail.
Poposed code
function Assert-AreEqualPath {
[CmdletBinding()]
param (
[Parameter(Mandatory)] [object] $Expected,
[Parameter(Mandatory)] [object] $Presented,
[Parameter()] [string] $Comment
)
$ex = &{ if ($Expected | Test-Path) { $Expected | Convert-Path} else {$Expected} }
$pr = &{ if ($Presented | Test-Path) { $Presented | Convert-Path} else {$Presented}}
# trim last '/' if exists
if($ex.EndsWith('/')){ $ex = $ex.Substring(0, $ex.Length - 1) }
if($pr.EndsWith('/')){ $pr = $pr.Substring(0, $pr.Length - 1) }
Assert-AreEqual -Expected $ex -Presented $pr -Comment ("Path not equal - " + $Comment)
}
function Assert-AreNotEqualPath {
[CmdletBinding()]
param (
[Parameter(Mandatory)] [object] $Expected,
[Parameter(Mandatory)] [object] $Presented,
[Parameter()] [string] $Comment
)
$ex = &{ if ($Expected | Test-Path) { $Expected | Convert-Path} else {$Expected} }
$pr = &{ if ($Presented | Test-Path) { $Presented | Convert-Path} else {$Presented}}
# trim last '/' if exists
if($ex.EndsWith('/')){ $ex = $ex.Substring(0, $ex.Length - 1) }
if($pr.EndsWith('/')){ $pr = $pr.Substring(0, $pr.Length - 1) }
Assert-AreNotEqual -Expected $ex -Presented $pr -Comment ("Path equal - " + $Comment)
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working