Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Set-Date don't work and admin-elevated test is silently skipped #3099

Copy link
Copy link
@iSazonov

Description

@iSazonov
Issue body actions
  1. 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.
  2. 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 remove Test-IsElevated from the tests and from Test.Helpers.psm1.

/cc @JamesWTruher @vors

  • Set-Date requires a fix (for Windows only?).

/cc @andschwa

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.