You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently Set-Date tests is silently skipped during elevated test phase in Start-PSPester because the tests use Test-IsElevated function instead of RequireAdminOnWindows 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: 11in \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-dateset-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,20179:09:32 PM
PS >set-date
cmdlet Set-Date at command pipeline position 1
Supply values for the following parameters:
Date: 2/4/2017set-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 remove Test-IsElevated from the tests and from Test.Helpers.psm1.
Set-Datetests is silently skipped during elevated test phase in Start-PSPester because the tests useTest-IsElevatedfunction instead ofRequireAdminOnWindowstag.The command is manually executed failed too (I tested on Windows 10 with PS Core beta 15):
RequireAdminOnWindowstag in order to run in admin-elevated phase.And we could remove
Test-IsElevatedfrom the tests and fromTest.Helpers.psm1./cc @JamesWTruher @vors
Set-Daterequires a fix (for Windows only?)./cc @andschwa