|
1 | 1 | # Copyright (c) Microsoft Corporation. |
2 | 2 | # Licensed under the MIT License. |
| 3 | + |
| 4 | +Import-Module HelpersCommon |
| 5 | + |
3 | 6 | Describe "Basic FileSystem Provider Tests" -Tags "CI" { |
4 | 7 | BeforeAll { |
5 | 8 | $testDir = "TestDir" |
@@ -621,6 +624,11 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" |
621 | 624 | } |
622 | 625 |
|
623 | 626 | Context "New-Item and hard/symbolic links" { |
| 627 | + AfterEach { |
| 628 | + # clean up created links after each test |
| 629 | + Remove-Item -Exclude (Split-Path -Leaf $realFile, $realDir, $realDir2) -Recurse $TestPath/* |
| 630 | + } |
| 631 | + |
624 | 632 | It "New-Item can create a hard link to a file" { |
625 | 633 | New-Item -ItemType HardLink -Path $hardLinkToFile -Value $realFile > $null |
626 | 634 | Test-Path $hardLinkToFile | Should -BeTrue |
@@ -664,6 +672,31 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows" |
664 | 672 | $link.LinkType | Should -BeExactly "SymbolicLink" |
665 | 673 | $link.Target | Should -BeExactly $real.ToString() |
666 | 674 | } |
| 675 | + |
| 676 | + It "New-Item can create a directory symbolic link to a directory using a relative path" -Skip:(-Not $IsWindows) { |
| 677 | + $target = Split-Path -Leaf $realDir |
| 678 | + New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $target > $null |
| 679 | + Test-Path $symLinkToDir | Should -BeTrue |
| 680 | + $real = Get-Item -Path $realDir |
| 681 | + $link = Get-Item -Path $symLinkToDir |
| 682 | + $link | Should -BeOfType System.IO.DirectoryInfo |
| 683 | + $link.LinkType | Should -BeExactly "SymbolicLink" |
| 684 | + $link.ResolvedTarget | Should -BeExactly $real.ToString() |
| 685 | + $link.Target | Should -BeExactly $target |
| 686 | + } |
| 687 | + |
| 688 | + It "New-Item can create a directory symbolic link to a directory using a relative path with .\" -Skip:(-Not $IsWindows) { |
| 689 | + $target = ".\$(Split-Path -Leaf $realDir)" |
| 690 | + New-Item -ItemType SymbolicLink -Path $symLinkToDir -Value $target > $null |
| 691 | + Test-Path $symLinkToDir | Should -BeTrue |
| 692 | + $real = Get-Item -Path $realDir |
| 693 | + $link = Get-Item -Path $symLinkToDir |
| 694 | + $link | Should -BeOfType System.IO.DirectoryInfo |
| 695 | + $link.LinkType | Should -BeExactly "SymbolicLink" |
| 696 | + $link.ResolvedTarget | Should -BeExactly $real.ToString() |
| 697 | + $link.Target | Should -BeExactly $target |
| 698 | + } |
| 699 | + |
667 | 700 | It "New-Item can create a directory junction to a directory" -Skip:(-Not $IsWindows) { |
668 | 701 | New-Item -ItemType Junction -Path $junctionToDir -Value $realDir > $null |
669 | 702 | Test-Path $junctionToDir | Should -BeTrue |
|
0 commit comments