go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/uptime/windows_test.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package uptime_test 5 6 import ( 7 "testing" 8 "time" 9 10 "github.com/stretchr/testify/assert" 11 "go.mondoo.com/cnquery/providers/os/resources/uptime" 12 ) 13 14 func TestWindowsUptime(t *testing.T) { 15 // uptime 16 data := ` 17 { 18 "Ticks": 2258270365, 19 "Days": 0, 20 "Hours": 0, 21 "Milliseconds": 827, 22 "Minutes": 3, 23 "Seconds": 45, 24 "TotalDays": 0.0026137388483796296, 25 "TotalHours": 0.06272973236111111, 26 "TotalMilliseconds": 225827.03650000002, 27 "TotalMinutes": 3.763783941666667, 28 "TotalSeconds": 225.8270365 29 } 30 ` 31 duration, err := uptime.ParseWindowsUptime(data) 32 assert.Nil(t, err) 33 assert.Equal(t, time.Duration(225827036500), duration) 34 assert.Equal(t, "3m45.8270365s", duration.String()) 35 }