mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Merge pull request 251 from dev/export-alias into develop
added export-alias basic tests
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
Describe "Export-Alias" {
|
||||
$testAliasDirectory = $env:TEMP + "/ExportAliasTestDirectory"
|
||||
$testAliases = "TestAliases"
|
||||
$fulltestpath = $testAliasDirectory + "/" + $testAliases
|
||||
|
||||
BeforeEach {
|
||||
New-Item -Path $testAliasDirectory -ItemType Directory -Force
|
||||
}
|
||||
|
||||
It "Should be able to create a file in the specified location"{
|
||||
Export-Alias $fulltestpath
|
||||
|
||||
|
||||
Test-Path $fulltestpath | Should be $true
|
||||
}
|
||||
|
||||
It "Should create a file with the list of aliases that match the expected list" {
|
||||
Export-Alias $fulltestpath
|
||||
|
||||
Test-Path $fulltestpath | Should Be $true
|
||||
|
||||
$actual = Get-Content $fulltestpath | Sort
|
||||
$expected = $(Get-Command -CommandType Alias)
|
||||
|
||||
for ( $i=0; $i -lt $expected.Length; $i++)
|
||||
{
|
||||
# We loop through the expected list and not the other because the output writes some comments to the file.
|
||||
$expected[$i] | Should Match $actual[$i].Name
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Remove-Item -Path $testAliasDirectory -Recurse -Force
|
||||
}
|
||||
Reference in New Issue
Block a user