mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +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
71 lines
2.1 KiB
PowerShell
71 lines
2.1 KiB
PowerShell
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
Describe "Set-Location" -Tags "CI" {
|
|
|
|
BeforeAll {
|
|
$startDirectory = Get-Location
|
|
|
|
if ($IsWindows)
|
|
{
|
|
$target = "C:\"
|
|
}
|
|
else
|
|
{
|
|
$target = "/"
|
|
}
|
|
}
|
|
|
|
AfterAll {
|
|
Set-Location $startDirectory
|
|
}
|
|
|
|
It "Should be able to be called without error" {
|
|
{ Set-Location $target } | Should Not Throw
|
|
}
|
|
|
|
It "Should be able to be called on different providers" {
|
|
{ Set-Location alias: } | Should Not Throw
|
|
{ Set-Location env: } | Should Not Throw
|
|
}
|
|
|
|
It "Should have the correct current location when using the set-location cmdlet" {
|
|
Set-Location $startDirectory
|
|
|
|
$(Get-Location).Path | Should Be $startDirectory.Path
|
|
}
|
|
|
|
It "Should be able to use the Path switch" {
|
|
{ Set-Location -Path $target } | Should Not Throw
|
|
}
|
|
|
|
It "Should generate a pathinfo object when using the Passthru switch" {
|
|
$result = Set-Location $target -PassThru
|
|
$result | Should BeOfType System.Management.Automation.PathInfo
|
|
}
|
|
|
|
It "Should accept path containing wildcard characters" {
|
|
$null = New-Item -ItemType Directory -Path "$TestDrive\aa"
|
|
$null = New-Item -ItemType Directory -Path "$TestDrive\ba"
|
|
$testPath = New-Item -ItemType Directory -Path "$TestDrive\[ab]a"
|
|
|
|
Set-Location $TestDrive
|
|
Set-Location -Path "[ab]a"
|
|
$(Get-Location).Path | Should BeExactly $testPath.FullName
|
|
}
|
|
|
|
Context 'Set-Location with no arguments' {
|
|
|
|
It 'Should go to $env:HOME when Set-Location run with no arguments from FileSystem provider' {
|
|
Set-Location 'TestDrive:\'
|
|
Set-Location
|
|
(Get-Location).Path | Should Be (Get-PSProvider FileSystem).Home
|
|
}
|
|
|
|
It 'Should go to $env:HOME when Set-Location run with no arguments from Env: provider' {
|
|
Set-Location 'Env:'
|
|
Set-Location
|
|
(Get-Location).Path | Should Be (Get-PSProvider FileSystem).Home
|
|
}
|
|
}
|
|
}
|