Set-Date don't work and admin-elevated test is silently skipped #3099
Description
- Currently
Set-Date
tests is silently skipped during elevated test phase in Start-PSPester because the tests useTest-IsElevated
function instead ofRequireAdminOnWindows
tag. - Really if we manually run the test - one is failed:
PS > Start-PSPester -Path \test\powershell\Modules\Microsoft.PowerShell.Utility\Set-Date.Tests.ps1 -binDir "C:\Program Files\PowerShell\6.0.0.15"
VERBOSE: Running pester tests at '\test\powershell\Modules\Microsoft.PowerShell.Utility\Set-Date.Tests.ps1'
with tag 'CI' and ExcludeTag 'Slow'
Describing Set-Date
[-] Set-Date should be able to set the date in an elevated context 850ms
Expected: the expression not to throw an exception. Message was {The parameter is incorrect}
from \test\powershell\Modules\Microsoft.PowerShell.Utility\Set-Date.Tests.ps1:11 char:22
+ { get-date | set-date } | Should not throw
+ ~~~~~~~~
at line: 11 in \test\powershell\Modules\Microsoft.PowerShell.Utility\Set-Date.Tests.ps1
11: { get-date | set-date } | Should not throw
[!] Set-Date should produce an error in a non-elevated context 90ms
Tests completed in 940ms
Passed: 0 Failed: 1 Skipped: 1 Pending: 0
The command is manually executed failed too (I tested on Windows 10 with PS Core beta 15):
PS > get-date | set-date
set-date : The parameter is incorrect
At line:1 char:12
+ get-date | set-date
+ ~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Date], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand
PS > get-date
Saturday, February 4, 2017 9:09:32 PM
PS > set-date
cmdlet Set-Date at command pipeline position 1
Supply values for the following parameters:
Date: 2/4/2017
set-date : The parameter is incorrect
At line:1 char:1
+ set-date
+ ~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-Date], Win32Exception
+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand
- So in Set-Date.Tests.ps1 the test must be marked by
RequireAdminOnWindows
tag in order to run in admin-elevated phase.
And we could removeTest-IsElevated
from the tests and fromTest.Helpers.psm1
.
/cc @JamesWTruher @vors
-
Set-Date
requires a fix (for Windows only?).
/cc @andschwa