Add 'RequireAdminOnWindows' tag to some tests suites

This commit is contained in:
Sergei Vorobev
2016-09-29 12:29:27 -07:00
parent 124a59b8a8
commit fdc69f0c3f
3 changed files with 36 additions and 17 deletions
@@ -1,8 +1,10 @@
Describe "Get-Process" -Tags "CI" {
Describe "Get-Process for admin" -Tags @('CI', 'RequireAdminOnWindows') {
It "Should support -IncludeUserName" {
(Get-Process powershell -IncludeUserName | Select-Object -First 1).UserName | Should Match $env:USERNAME
}
}
Describe "Get-Process" -Tags "CI" {
# These tests are no good, please replace!
It "Should return a type of Object[] for Get-Process cmdlet" -Pending:$IsOSX {
(Get-Process).GetType().BaseType | Should Be 'array'
@@ -104,6 +104,36 @@ Describe "New-Item" -Tags "CI" {
Test-Path $FullyQualifiedFile | Should Be $false
}
It "Should create a hard link of a file without error" {
New-Item -Name $testfile -Path $tmpDirectory -ItemType file
Test-Path $FullyQualifiedFile | Should Be $true
New-Item -ItemType HardLink -Target $FullyQualifiedFile -Name $testlink -Path $tmpDirectory
Test-Path $FullyQualifiedLink | Should Be $true
$fileInfo = Get-ChildItem $FullyQualifiedLink
$fileInfo.Target | Should Be $null
$fileInfo.LinkType | Should Be "HardLink"
}
}
# More precisely these tests require SeCreateSymbolicLinkPrivilege.
# You can see list of priveledges with `whoami /priv`.
# In the default windows setup, Admin user has this priveledge, but regular users don't.
Describe "New-Item with links" -Tags @('CI', 'RequireAdminOnWindows') {
$tmpDirectory = $TestDrive
$testfile = "testfile.txt"
$testfolder = "newDirectory"
$testlink = "testlink"
$FullyQualifiedFile = Join-Path -Path $tmpDirectory -ChildPath $testfile
$FullyQualifiedFolder = Join-Path -Path $tmpDirectory -ChildPath $testfolder
$FullyQualifiedLink = Join-Path -Path $tmpDirectory -ChildPath $testlink
BeforeEach {
Clean-State
}
It "Should create a symbolic link of a file without error" {
New-Item -Name $testfile -Path $tmpDirectory -ItemType file
Test-Path $FullyQualifiedFile | Should Be $true
@@ -141,17 +171,4 @@ Describe "New-Item" -Tags "CI" {
# Remove the link explicitly to avoid broken symlink issue
Remove-Item $FullyQualifiedLink -Force
}
It "Should create a hard link of a file without error" {
New-Item -Name $testfile -Path $tmpDirectory -ItemType file
Test-Path $FullyQualifiedFile | Should Be $true
New-Item -ItemType HardLink -Target $FullyQualifiedFile -Name $testlink -Path $tmpDirectory
Test-Path $FullyQualifiedLink | Should Be $true
$fileInfo = Get-ChildItem $FullyQualifiedLink
$fileInfo.Target | Should Be $null
$fileInfo.LinkType | Should Be "HardLink"
}
}
+3 -3
View File
@@ -65,17 +65,17 @@ function RunTestCase
}
}
Describe "Validate that get-help <cmdletName> works" -Tags "CI" {
Describe "Validate that get-help <cmdletName> works" -Tags @('CI', 'RequireAdminOnWindows') {
RunTestCase -tag "CI"
}
Describe "Validate Get-Help for all cmdlets in 'Microsoft.PowerShell.Core'" -Tags "Feature" {
Describe "Validate Get-Help for all cmdlets in 'Microsoft.PowerShell.Core'" -Tags @('Feature', 'RequireAdminOnWindows') {
RunTestCase -tag "Feature"
}
Describe "Validate that Get-Help returns provider-specific help" -Tags "CI" {
Describe "Validate that Get-Help returns provider-specific help" -Tags @('CI', 'RequireAdminOnWindows') {
BeforeAll {
$namespaces = @{
command = 'http://schemas.microsoft.com/maml/dev/command/2004/10'