forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftwareinventory_test.go
91 lines (76 loc) · 1.92 KB
/
softwareinventory_test.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var softwareInventoryBody = `{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.etag": "W/\"918DA6A4\"",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/1/",
"@odata.type": "#SoftwareInventory.v1_0_0.SoftwareInventory",
"Id": "1",
"Description": "SystemBMC",
"Name": "Bob",
"Oem": {},
"Status": {
"Health": "OK",
"State": "Enabled"
},
"RelatedItem": [
{
"@odata.id": "/redfish/v1/Managers/1"
}
],
"Version": "1.2.3.4",
"LowestSupportedVersion": "1.1.1.1",
"Manufacturer": "BobCo",
"ReleaseDate": "1/1/2020",
"SoftwareId": "1234",
"UefiDevicePaths": [ "/1", "/2" ],
"Updateable": true,
"WriteProtected": false
}`
func TestSoftwareInventory(t *testing.T) {
var result SoftwareInventory
err := json.NewDecoder(strings.NewReader(softwareInventoryBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.Description != "SystemBMC" {
t.Errorf("Description was wrong")
}
if result.Status.Health != "OK" {
t.Errorf("Health is wrong")
}
if result.Version != "1.2.3.4" {
t.Errorf("Version is wrong")
}
if result.LowestSupportedVersion != "1.1.1.1" {
t.Errorf("LowestSupportedVersion is wrong")
}
if result.Manufacturer != "BobCo" {
t.Errorf("Manufacturer is wrong")
}
if len(result.relatedItem) != 1 || result.relatedItem[0] != "/redfish/v1/Managers/1" {
t.Errorf("Unexpected related items: %#v", result.relatedItem)
}
if result.ReleaseDate != "1/1/2020" {
t.Errorf("ReleaseDate is wrong")
}
if result.SoftwareID != "1234" {
t.Errorf("SoftwareID is wrong")
}
if result.UefiDevicePaths[0] != "/1" {
t.Errorf("UefiDevicePaths is wrong")
}
if result.Updateable != true {
t.Errorf("Updateable is wrong")
}
if result.WriteProtected != false {
t.Errorf("WriteProtected is wrong")
}
}