forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPester.Commands.Cmdlets.GetCommand.Tests.ps1
More file actions
52 lines (43 loc) · 1.79 KB
/
Copy pathPester.Commands.Cmdlets.GetCommand.Tests.ps1
File metadata and controls
52 lines (43 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##
## Copyright (c) Microsoft Corporation, 2015
##
Describe "Tests Get-Command with relative paths and wildcards" -Tag "CI" {
BeforeAll {
# Create temporary EXE command files
$file1 = Setup -f WildCardCommandA.exe -pass
$file2 = Setup -f WildCardCommand[B].exe -pass
#$null = New-Item -ItemType File -Path (Join-Path $TestDrive WildCardCommandA.exe) -ErrorAction Ignore
#$null = New-Item -ItemType File -Path (Join-Path $TestDRive WildCardCommand[B].exe) -ErrorAction Ignore
if ( $IsLinux -or $IsOSX ) {
/bin/chmod 777 "$file1"
/bin/chmod 777 "$file2"
}
}
It "Test wildcard with drive relative directory path" {
$pathName = Join-Path $TestDrive "WildCardCommandA*"
$driveOffset = $pathName.IndexOf(":")
$pathName = $pathName.Substring($driveOffset + 1)
$result = Get-Command -Name $pathName
$result | Should Not Be $null
$result.Name | Should Be WildCardCommandA.exe
}
It "Test wildcard with relative directory path" {
push-location $TestDrive
$result = Get-Command -Name .\WildCardCommandA*
pop-location
$result | Should Not Be $null
$result | Should Be WildCardCommandA.exe
}
It "Test with PowerShell wildcard and relative path" {
push-location $TestDrive
# This should use the wildcard to find WildCardCommandA.exe
$result = Get-Command -Name .\WildCardCommand[A].exe
$result | Should Not Be $null
$result | Should Be WildCardCommandA.exe
# This should find the file WildCardCommand[B].exe
$result = Get-Command -Name .\WildCardCommand[B].exe
$result | Should Not Be $null
$result | Should Be WildCardCommand[B].exe
Pop-Location
}
}