Commits

Aaron Jensen committed 4a9efcd

Improving Install-Junction tests so they work on machines where Temp directory isn't named Temp and the $env:Temp value contains only 8.3 names.

Comments (0)

Files changed (1)

Test/FileSystem/Test-InstallJunction.ps1

 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-
+# To convert C:\Users\schedu~1 to C:\Users\scheduleuser
+$tempDir = [IO.Path]::GetFullPath( $env:TEMP )
 $junctionPath = $null
 
 function Start-Test
 {
     & (Join-Path $TestDir ..\..\Carbon\Import-Carbon.ps1 -Resolve)
-    $junctionPath = Join-Path $env:Temp ('Carbon_Test-InstallJunction_{0}' -f ([IO.Path]::GetRandomFileName()))
+    $junctionPath = Join-Path $tempDir ('Carbon_Test-InstallJunction_{0}' -f ([IO.Path]::GetRandomFileName()))
     $Error.Clear()
 }
 
 function Test-ShouldCreateTargetIfItDoesNotExist
 {
     $target = 'Carbon_Test-InstallJunction_{0}' -f [IO.Path]::GetRandomFileName()
-    $target = Join-Path -Path $env:TEMP -ChildPath $target
+    $target = Join-Path -Path $tempDir -ChildPath $target
     Assert-DirectoryDoesNotExist $target
     Install-Junction -Link $junctionPath -Target $target -Force
     Assert-Equal 0 $Error.Count
 
 function Test-ShouldCreateJunctionWithRelativePaths
 {
-    Push-Location $env:TEMP
+    Push-Location $tempDir
     try
     {
-        $target = '..\Temp'
+        $target = ('..\{0}' -f (Split-Path -Leaf $tempDir))
         $link = '.\{0}' -f (Split-Path -Leaf -Path $junctionPath)
 
         Install-Junction -Link $link -Target $target
 
-        Assert-Junction -ExpectedTarget $env:Temp
+        Assert-Junction -ExpectedTarget $tempDir
     }
     finally
     {