Files
PowerShell-PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1
T
Travis Plunk 965552873c Add Linux VSTS CI (#7527)
Update Start-PSPester and Start-PSxUnit to upload test results when running in VSTS
Disable tests which require non-root using when running as root
remove verifications in Test-Connection tests which verify buggy behavior
Skip tests which don't behave correctly in VSTS (due to running in a container?)
- Test-Connection - #7528
- Set-Date - #7529
2018-08-14 16:23:50 -07:00

25 lines
950 B
PowerShell

# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
Import-Module HelpersCommon
Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') {
# Fails in VSTS Linux with Operation not permitted
It "Set-Date should be able to set the date in an elevated context" -Skip:(Test-IsVstsLinux) {
{ Get-Date | Set-Date } | Should -Not -Throw
}
# Fails in VSTS Linux with Operation not permitted
It "Set-Date should be able to set the date with -Date parameter" -Skip:(Test-IsVstsLinux) {
$target = Get-Date
$expected = $target
Set-Date -Date $target | Should -Be $expected
}
}
Describe "Set-Date" -Tag 'CI' {
It "Set-Date should produce an error in a non-elevated context" {
{ Get-Date | Set-Date } | Should -Throw -ErrorId "System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.SetDateCommand"
}
}