1
- BeforeDiscovery { Import-Module " $PSScriptRoot /../../../src/common/Windows.psm1" }
1
+ BeforeDiscovery {
2
+ Import-Module " $PSScriptRoot /../../../src/common/Windows.psm1"
3
+ }
2
4
3
5
Describe ' Get-LastSyncTime Tests' {
6
+ BeforeAll {
7
+ # Always mock w32tm for consistent cross-platform testing
8
+ function Global :w32tm {
9
+ param ($Command , $SubCommand )
10
+ if ($Command -eq ' /query' -and $SubCommand -eq ' /status' ) {
11
+ return @ (
12
+ ' Leap Indicator: 0(no warning)' ,
13
+ ' Stratum: 2 (secondary reference - syncd by (S)NTP)' ,
14
+ ' Precision: -6 (15.625ms per tick)' ,
15
+ ' Root Delay: 0.0000000s' ,
16
+ ' Root Dispersion: 10.0000000s' ,
17
+ ' ReferenceId: 0x00000000 (unspecified)' ,
18
+ ' Last Successful Sync Time: 12/25/2023 10:30:45 AM' ,
19
+ ' Source: time.windows.com' ,
20
+ ' Poll Interval: 6 (64s)'
21
+ )
22
+ }
23
+ return @ ()
24
+ }
25
+ }
26
+
4
27
Context ' Basic Functionality' {
5
28
It ' Should return a DateTime object' {
6
29
$Result = Get-LastSyncTime
@@ -10,7 +33,9 @@ Describe 'Get-LastSyncTime Tests' {
10
33
11
34
It ' Should return Unix epoch when w32tm fails or returns unparseable data' {
12
35
# Mock w32tm to return invalid data
13
- Mock w32tm { return ' Invalid output' } - ModuleName Windows
36
+ function Global :w32tm {
37
+ return ' Invalid output'
38
+ }
14
39
15
40
$Result = Get-LastSyncTime
16
41
0 commit comments