...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package resource_test
16
17 import (
18 "testing"
19
20 "github.com/stretchr/testify/assert"
21 "github.com/stretchr/testify/require"
22 "golang.org/x/sys/windows/registry"
23
24 "go.opentelemetry.io/otel/sdk/resource"
25 )
26
27 func TestPlatformOSDescription(t *testing.T) {
28 osDescription, err := resource.PlatformOSDescription()
29
30 require.NoError(t, err)
31 require.Regexp(t, `^(\w+\s)+\(\d+\)\s\[Version\s\d+(\.\d+){3}\]$`, osDescription)
32 }
33
34 func TestReadRegistryValues(t *testing.T) {
35 k, err := registry.OpenKey(
36 registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE)
37
38 require.NoError(t, err, "should open Windows CurrentVersion registry key")
39
40 defer k.Close()
41
42 assert.NotEmpty(t, resource.ReadProductName(k), "should read ProductName")
43 assert.NotEmpty(t, resource.ReadReleaseID(k), "should read ReleaseID")
44 assert.NotEmpty(t, resource.ReadCurrentMajorVersionNumber(k), "should read CurrentMajorVersionNumber")
45 assert.NotEmpty(t, resource.ReadCurrentMinorVersionNumber(k), "should read CurrentMinorVersionNumber")
46 assert.NotEmpty(t, resource.ReadCurrentBuildNumber(k), "should read CurrentBuildNumber")
47 assert.NotEmpty(t, resource.ReadUBR(k), "should read UBR")
48 assert.NotPanics(t, func() { resource.ReadDisplayVersion(k) }, "should not panic when reading DisplayVersion")
49 }
50
View as plain text