mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
* Add CI for win-arm64 * Add common function to test for windows arm64 * Update because string where items need investigation --------- Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
42 lines
1.6 KiB
PowerShell
42 lines
1.6 KiB
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
Import-Module HelpersCommon
|
|
|
|
Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
|
|
BeforeAll {
|
|
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("SetDate", $true)
|
|
}
|
|
AfterAll {
|
|
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook("SetDate", $false)
|
|
}
|
|
|
|
It "Set-Date should be able to set the date in an elevated context" {
|
|
{ Get-Date | Set-Date } | Should -Not -Throw
|
|
}
|
|
|
|
# Check the individual properties as the types may be different
|
|
It "Set-Date should be able to set the date with -Date parameter" {
|
|
$target = Get-Date
|
|
$expected = $target
|
|
$observed = Set-Date -Date $target
|
|
# do not test dayofweek because the number of the day is different between native and managed
|
|
$observed.Day | Should -Be $expected.Day
|
|
$observed.Hour | Should -Be $expected.Hour
|
|
$observed.Minutes | Should -Be $expected.Minutes
|
|
$observed.Month | Should -Be $expected.Month
|
|
$observed.Second | Should -Be $expected.Second
|
|
$observed.Year | Should -Be $expected.Year
|
|
}
|
|
}
|
|
|
|
Describe "Set-Date" -Tag 'CI' {
|
|
It "Set-Date should produce an error in a non-elevated context" {
|
|
if (Test-IsElevated) {
|
|
Set-ItResult -Skipped -Because "must NOT be run as admin"
|
|
}
|
|
|
|
{ Get-Date | Set-Date } | Should -Throw -ErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
|
|
}
|
|
}
|