-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathwmi_windows_test.go
More file actions
56 lines (44 loc) · 1.29 KB
/
wmi_windows_test.go
File metadata and controls
56 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) Mondoo, Inc.
// SPDX-License-Identifier: BUSL-1.1
//go:build windows
package windows
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestToString(t *testing.T) {
t.Run("nil returns empty string", func(t *testing.T) {
assert.Equal(t, "", toString(nil))
})
t.Run("non-nil returns value", func(t *testing.T) {
s := "hello"
assert.Equal(t, "hello", toString(&s))
})
t.Run("empty string returns empty string", func(t *testing.T) {
s := ""
assert.Equal(t, "", toString(&s))
})
}
func TestIntToString(t *testing.T) {
t.Run("nil returns empty string", func(t *testing.T) {
assert.Equal(t, "", intToString(nil))
})
t.Run("non-nil returns string representation", func(t *testing.T) {
i := 42
assert.Equal(t, "42", intToString(&i))
})
t.Run("zero returns 0", func(t *testing.T) {
i := 0
assert.Equal(t, "0", intToString(&i))
})
}
func TestGetWmiInformation_Integration(t *testing.T) {
conn := &mockLocalConnection{}
info, err := GetWmiInformation(conn)
require.NoError(t, err)
require.NotNil(t, info)
assert.NotEmpty(t, info.Version, "Version should not be empty")
assert.NotEmpty(t, info.BuildNumber, "BuildNumber should not be empty")
assert.NotEmpty(t, info.Caption, "Caption should not be empty")
}