address some review feedback
This commit is contained in:
parent
f4ed351f86
commit
3ceca01b64
3 changed files with 29 additions and 17 deletions
|
@ -22,4 +22,28 @@ function Wait-CompleteExecution
|
|||
}
|
||||
return $true
|
||||
}
|
||||
export-modulemember -function Wait-CompleteExecution
|
||||
|
||||
function Test-IsElevated
|
||||
{
|
||||
$IsElevated = $False
|
||||
if ( $IsWindows ) {
|
||||
# on Windows we can determine whether we're executing in an
|
||||
# elevated context
|
||||
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $identity
|
||||
if ($windowsPrincipal.IsInRole("Administrators") -eq 1)
|
||||
{
|
||||
$IsElevated = $true
|
||||
}
|
||||
}
|
||||
else {
|
||||
# on Linux, tests run via sudo will generally report "root" for whoami
|
||||
if ( (whoami) -match "root" ) {
|
||||
$IsElevated = $true
|
||||
}
|
||||
}
|
||||
return $IsElevated
|
||||
}
|
||||
|
||||
export-modulemember -function Wait-CompleteExecution,Test-IsElevated
|
||||
|
||||
|
|
|
@ -12,9 +12,8 @@ $script2 = @'
|
|||
"line 3"
|
||||
'@
|
||||
|
||||
$root = git rev-parse --show-toplevel
|
||||
$pestertestroot = join-path $root test/powershell
|
||||
$common = join-path $pestertestroot Common
|
||||
$testroot = resolve-path (join-path $psscriptroot ../../..)
|
||||
$common = join-path $testroot Common
|
||||
$helperModule = join-path $common Test.Helpers.psm1
|
||||
|
||||
Describe "Breakpoints when set should be hit" -tag "CI" {
|
||||
|
|
|
@ -3,19 +3,8 @@
|
|||
# determine whether we're elevated
|
||||
Describe "Set-Date" -Tag "CI" {
|
||||
BeforeAll {
|
||||
if ( $IsWindows ) {
|
||||
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $identity
|
||||
if ($windowsPrincipal.IsInRole("Administrators") -eq 1) { $IsElevated = $true } else { $IsElevated = $false }
|
||||
}
|
||||
else {
|
||||
if ( (whoami) -match "root" ) {
|
||||
$IsElevated = $true
|
||||
}
|
||||
else {
|
||||
$IsElevated = $false
|
||||
}
|
||||
}
|
||||
Import-Module (join-path $psscriptroot "../../Common/Test.Helpers.psm1")
|
||||
$IsElevated = Test-IsElevated
|
||||
}
|
||||
It "Set-Date should be able to set the date in an elevated context" -Skip:(! $IsElevated) {
|
||||
{ get-date | set-date } | Should not throw
|
||||
|
|
Loading…
Reference in a new issue