2016-03-04 22:48:30 +00:00
|
|
|
Describe "Set-Location" {
|
2015-12-01 18:30:27 +00:00
|
|
|
$startDirectory = Get-Location
|
2015-12-28 19:05:48 +00:00
|
|
|
|
2016-03-04 22:39:18 +00:00
|
|
|
if ($IsWindows)
|
2015-12-01 18:30:27 +00:00
|
|
|
{
|
2016-03-04 22:52:27 +00:00
|
|
|
$target = "C:\"
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-04 22:52:27 +00:00
|
|
|
$target = "/"
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able to be called without error" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ Set-Location $target } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able to be called on different providers" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ Set-Location alias: } | Should Not Throw
|
|
|
|
{ Set-Location env: } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able use the cd alias without error" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ cd $target } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able to use the chdir alias without error" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ chdir $target } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able to use the sl alias without error" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ sl $target } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should have the correct current location when using the set-location cmdlet" {
|
2016-03-04 22:52:27 +00:00
|
|
|
Set-Location $startDirectory
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$(Get-Location).Path | Should Be $startDirectory.Path
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should have the correct current location when using the cd alias" {
|
2016-03-04 22:52:27 +00:00
|
|
|
cd $target
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$(Get-Location).Path | Should Be $target
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should have the correct current location when using the chdir alias" {
|
2016-03-04 22:52:27 +00:00
|
|
|
chdir $target
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$(Get-Location).Path | Should Be $target
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should have the correct current location when using the chdir alias" {
|
2016-03-04 22:52:27 +00:00
|
|
|
sl $target
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2016-03-04 22:52:27 +00:00
|
|
|
$(Get-Location).Path | Should Be $target
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should be able to use the Path switch" {
|
2016-03-04 22:52:27 +00:00
|
|
|
{ Set-Location -Path $target } | Should Not Throw
|
2015-12-01 18:30:27 +00:00
|
|
|
}
|
2015-10-23 17:01:44 +00:00
|
|
|
|
2015-12-01 18:30:27 +00:00
|
|
|
It "Should generate a pathinfo object when using the Passthru switch" {
|
2016-03-04 22:52:27 +00:00
|
|
|
$(Set-Location $target -PassThru).GetType().Name | Should Be PathInfo
|
2015-10-23 17:01:44 +00:00
|
|
|
}
|
2015-12-01 18:30:27 +00:00
|
|
|
|
|
|
|
Set-Location $startDirectory
|
2015-10-23 17:01:44 +00:00
|
|
|
}
|