mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Merge pull request #601 from PowerShell/newitem
Modify New-Item to support Symbolic Link on Linux
This commit is contained in:
+1
-1
Submodule src/libpsl-native updated: 8650c6a6a1...19dbaaf54c
+1
-1
Submodule src/monad updated: 07f23acd10...e0dc79b074
@@ -1,5 +1,10 @@
|
||||
function Clean-State
|
||||
{
|
||||
if (Test-Path $FullyQualifiedLink)
|
||||
{
|
||||
Remove-Item $FullyQualifiedLink -Force
|
||||
}
|
||||
|
||||
if (Test-Path $FullyQualifiedFile)
|
||||
{
|
||||
Remove-Item $FullyQualifiedFile -Force
|
||||
@@ -7,7 +12,7 @@
|
||||
|
||||
if (Test-Path $FullyQualifiedFolder)
|
||||
{
|
||||
Remove-Item $FullyQualifiedFolder -Recurse -Force
|
||||
Remove-Item $FullyQualifiedFolder -Force
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +20,10 @@ Describe "New-Item" {
|
||||
$tmpDirectory = $TestDrive
|
||||
$testfile = "testfile.txt"
|
||||
$testfolder = "newDirectory"
|
||||
$testlink = "testlink"
|
||||
$FullyQualifiedFile = Join-Path -Path $tmpDirectory -ChildPath $testfile
|
||||
$FullyQualifiedFolder = Join-Path -Path $tmpDirectory -ChildPath $testfolder
|
||||
$FullyQualifiedLink = Join-Path -Path $tmpDirectory -ChildPath $testlink
|
||||
|
||||
BeforeEach {
|
||||
Clean-State
|
||||
@@ -92,4 +99,25 @@ Describe "New-Item" {
|
||||
|
||||
Test-Path $FullyQualifiedFile | Should Be $false
|
||||
}
|
||||
|
||||
It "Should create a symbolic link of a file without error" {
|
||||
New-Item -Name $testfile -Path $tmpDirectory -ItemType file
|
||||
Test-Path $FullyQualifiedFile | Should Be $true
|
||||
|
||||
New-Item -ItemType SymbolicLink -Target $FullyQualifiedFile -Name $testlink -Path $tmpDirectory
|
||||
Test-Path $FullyQualifiedLink | Should Be $true
|
||||
}
|
||||
|
||||
It "Should create a symbolic link from directory without error" {
|
||||
New-Item -Name $testFolder -Path $tmpDirectory -ItemType directory
|
||||
Test-Path $FullyQualifiedFolder | Should Be $true
|
||||
|
||||
New-Item -ItemType SymbolicLink -Target $FullyQualifiedFolder -Name $testlink -Path $tmpDirectory
|
||||
Test-Path $FullyQualifiedLink | Should Be $true
|
||||
|
||||
# Remove the link explicitly to avoid broken symlink issue
|
||||
Remove-Item $FullyQualifiedLink -Force
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user