Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: ScheduledTask: Allow better handling of multiple time zones #440

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix integration test
  • Loading branch information
Borgquite committed Nov 29, 2024
commit 1d02de36bb5734796bb229fc26b91edac38027ed
51 changes: 4 additions & 47 deletions tests/Integration/DSC_ScheduledTask.Integration.Tests.ps1
Original file line number Diff line number Diff line change
@@ -291,22 +291,12 @@ Describe "$($script:dscResourceName)_Integration" {
}

Context 'When a scheduled task is created and synchronize across time zone is disabled' {
BeforeDiscovery {
$expectedStartTime = '2018-10-01T01:00:00'
}

BeforeAll {
$currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneDisabled'
$configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig)
$configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof')

$expectedStartTime = '2018-10-01T01:00:00'

InModuleScope -Parameters @{
expectedStartTime = $expectedStartTime
} -ScriptBlock {
$script:expectedStartTime = $expectedStartTime
}
}

AfterAll {
@@ -347,31 +337,20 @@ Describe "$($script:dscResourceName)_Integration" {
$current.Enable | Should -BeTrue
}

It "Should have the trigger startBoundary set to '$expectedStartTime'" {
It 'Should have the trigger startBoundary set to ''2018-10-01T01:00:00''' {
$task = (Get-ScheduledTask -TaskName 'Test task sync across time zone disabled')
$task.Triggers[0].StartBoundary | Should -Be $expectedStartTime
}
}

Context 'When a scheduled task is created and synchronize across time zone is enabled positive' {
BeforeDiscovery {
$configuredStartTime = '2018-10-01T01:00:00+08:00'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')
}

BeforeAll {
$currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabledPositive'
$configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig)
$configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof')

$configuredStartTime = '2018-10-01T01:00:00+08:00'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')

InModuleScope -Parameters @{
expectedStartTime = $expectedStartTime
} -ScriptBlock {
$script:expectedStartTime = $expectedStartTime
}
}

AfterAll {
@@ -412,31 +391,20 @@ Describe "$($script:dscResourceName)_Integration" {
$current.Enable | Should -BeTrue
}

It "Should have the trigger startBoundary set to '$expectedStartTime'" {
It 'Should have the trigger startBoundary set to ''2018-09-30T17:00:00+00:00''' {
$task = (Get-ScheduledTask -TaskName 'Test task sync across time zone enabled positive')
$task.Triggers[0].StartBoundary | Should -Be $expectedStartTime
}
}

Context 'When a scheduled task is created and synchronize across time zone is enabled negative' {
BeforeDiscovery {
$configuredStartTime = '2018-10-01T01:00:00-08:00'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')
}

BeforeAll {
$currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabledNegative'
$configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig)
$configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof')

$configuredStartTime = '2018-10-01T01:00:00-08:00'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')

InModuleScope -Parameters @{
expectedStartTime = $expectedStartTime
} -ScriptBlock {
$script:expectedStartTime = $expectedStartTime
}
}

AfterAll {
@@ -477,31 +445,20 @@ Describe "$($script:dscResourceName)_Integration" {
$current.Enable | Should -BeTrue
}

It "Should have the trigger startBoundary set to '$expectedStartTime'" {
It 'Should have the trigger startBoundary set to ''2018-10-01T09:00:00+00:00''' {
$task = (Get-ScheduledTask -TaskName 'Test task sync across time zone enabled negative')
$task.Triggers[0].StartBoundary | Should -Be $expectedStartTime
}
}

Context 'When a scheduled task is created and synchronize across time zone is enabled zulu' {
BeforeDiscovery {
$configuredStartTime = '2018-10-01T01:00:00Z'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')
}

BeforeAll {
$currentConfig = 'ScheduledTaskOnceSynchronizeAcrossTimeZoneEnabledZulu'
$configDir = (Join-Path -Path $TestDrive -ChildPath $currentConfig)
$configMof = (Join-Path -Path $configDir -ChildPath 'localhost.mof')

$configuredStartTime = '2018-10-01T01:00:00Z'
$expectedStartTime = (Get-Date -Date $configuredStartTime).ToUniversalTime().ToString((Get-Culture).DateTimeFormat.SortableDateTimePattern + 'zzz')

InModuleScope -Parameters @{
expectedStartTime = $expectedStartTime
} -ScriptBlock {
$script:expectedStartTime = $expectedStartTime
}
}

AfterAll {
@@ -542,7 +499,7 @@ Describe "$($script:dscResourceName)_Integration" {
$current.Enable | Should -BeTrue
}

It "Should have the trigger startBoundary set to '$expectedStartTime'" {
It 'Should have the trigger startBoundary set to ''2018-10-01T01:00:00+00:00''' {
$task = (Get-ScheduledTask -TaskName 'Test task sync across time zone enabled zulu')
$task.Triggers[0].StartBoundary | Should -Be $expectedStartTime
}