Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
Push-Location.Tests.ps158 linesDownload Raw Back to Microsoft.PowerShell.Management
1# Copyright (c) Microsoft Corporation.2# Licensed under the MIT License.3Describe "Test-Push-Location" -Tags "CI" {4    New-Variable -Name startDirectory -Value $(Get-Location).Path -Scope Global -Force5 6    BeforeEach { Set-Location $startDirectory }7 8    It "Should be called without error" {9	{ Push-Location } | Should -Not -Throw10    }11 12    It "Should be able to push to the root directory" {13	# this works cross-platform14	{ Push-Location / } | Should -Not -Throw15    }16 17    It "Should be able to use relative path to parent" {18	{ Push-Location .. } | Should -Not -Throw19    }20 21    It "Should be able to use relative path to grandparent" {22	Test-Path ../.. | Should -BeTrue23 24	{ Push-Location ../.. } | Should -Not -Throw25    }26 27    It "Should be able to push twice" {28	{ Push-Location .. } | Should -Not -Throw29	{ Push-Location .. } | Should -Not -Throw30    }31 32    It "Should be able to take a piped variable" {33	{ ".." | Push-Location } | Should -Not -Throw34    }35 36    It "Should be able to call the pushd alias" {37	{ pushd } | Should -Not -Throw38    }39 40    It "Should be able to push to the same location between the alias and the cmdlet" {41	pushd ..42	$aliasDirectory = $(Get-Location).Path43 44	Set-Location $startDirectory45	Push-Location ..46	$cmdletDirectory = $(Get-Location).Path47 48	$aliasDirectory | Should -BeExactly $cmdletDirectory49    }50 51    It "Should produce a pathinfo object when the passthru parameter is used" {52        Push-Location .. -PassThru | ForEach-Object { $_ | Should -BeOfType System.Management.Automation.PathInfo }53    }54 55    # final cleanup56    Set-Location $startDirectory57}58