| 1 | |
| 2 | |
| 3 | |
| 4 | package osutil |
| 5 | |
| 6 | import ( |
| 7 | "strings" |
| 8 | "testing" |
| 9 | |
| 10 | "gotest.tools/v3/assert" |
| 11 | ) |
| 12 | |
| 13 | func TestMachineID(t *testing.T) { |
| 14 | t.Log(MachineID()) |
| 15 | } |
| 16 | |
| 17 | func TestParseIOPlatformUUIDFromIOPlatformExpertDevice(t *testing.T) { |
| 18 | ioPlatformExpertDevice := ` |
| 19 | <?xml version="1.0" encoding="UTF-8"?> |
| 20 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 21 | <plist version="1.0"> |
| 22 | <dict> |
| 23 | <key>IOObjectClass</key> |
| 24 | <string>IORegistryEntry</string> |
| 25 | <key>IORegistryEntryChildren</key> |
| 26 | <array> |
| 27 | <dict> |
| 28 | <key>foo</key> |
| 29 | <string>foo value</string> |
| 30 | <key>IOPlatformUUID</key> |
| 31 | <string>1A008DA1-06E0-49AB-8EC9-88E9C85F67FB</string> |
| 32 | <key>bar</key> |
| 33 | <string>bar value</string> |
| 34 | </dict> |
| 35 | </array> |
| 36 | <key>IORegistryEntryName</key> |
| 37 | <string>Root</string> |
| 38 | </dict> |
| 39 | </plist> |
| 40 | ` |
| 41 | got, err := parseIOPlatformUUIDFromIOPlatformExpertDevice(strings.NewReader(ioPlatformExpertDevice)) |
| 42 | assert.NilError(t, err) |
| 43 | assert.Equal(t, "1A008DA1-06E0-49AB-8EC9-88E9C85F67FB", got) |
| 44 | } |