mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files. Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks. Separate PR coming to update contribution document for new source files: #6140 Manually reviewed each change. Fix #6073
55 lines
2.1 KiB
PowerShell
55 lines
2.1 KiB
PowerShell
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
Describe "Convert-Path tests" -Tag CI {
|
|
It "Convert-Path should handle provider qualified paths" {
|
|
Convert-Path "FileSystem::${TESTDRIVE}" | should be "${TESTDRIVE}"
|
|
}
|
|
It "Convert-Path should return the proper path" {
|
|
Convert-Path "$TESTDRIVE" | Should be "$TESTDRIVE"
|
|
}
|
|
It "Convert-Path supports pipelined input" {
|
|
"$TESTDRIVE" | Convert-Path | Should be "$TESTDRIVE"
|
|
}
|
|
It "Convert-Path supports pipelined input by property name" {
|
|
get-item $TESTDRIVE | Convert-Path | Should be "$TESTDRIVE"
|
|
}
|
|
It "Convert-Path without arguments is an error" {
|
|
try {
|
|
$ps = [powershell]::Create()
|
|
$ps.AddCommand("Convert-Path").Invoke()
|
|
throw "Execution should not have reached here"
|
|
}
|
|
catch {
|
|
$_.fullyqualifiederrorid | should be ParameterBindingException
|
|
}
|
|
}
|
|
It "Convert-Path with null path is an error" {
|
|
try {
|
|
Convert-Path -path ""
|
|
throw "Execution should not have reached here"
|
|
}
|
|
catch {
|
|
$_.fullyqualifiederrorid | should be "ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertPathCommand"
|
|
}
|
|
}
|
|
It "Convert-Path with non-existing non-filesystem path is an error" {
|
|
try {
|
|
Convert-Path -path "env:thisvariableshouldnotexist" -ea stop
|
|
throw "Execution should not have reached here"
|
|
}
|
|
catch {
|
|
$_.fullyqualifiederrorid | should be "PathNotFound,Microsoft.PowerShell.Commands.ConvertPathCommand"
|
|
}
|
|
}
|
|
It "Convert-Path can handle multiple directories" {
|
|
$d1 = Setup -D dir1 -pass
|
|
$d2 = Setup -D dir2 -pass
|
|
$result = convert-path "${TESTDRIVE}/dir?"
|
|
$result.count | Should be 2
|
|
$result -join "," | should be (@("$d1","$d2") -join ",")
|
|
}
|
|
It "Convert-Path should return something which exists" {
|
|
Convert-Path $TESTDRIVE | Test-Path | should be $true
|
|
}
|
|
}
|