forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlicense_test.go
50 lines (45 loc) · 1.26 KB
/
license_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"fmt"
"strings"
"testing"
)
var licenseBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#License.License",
"@odata.id": "/redfish/v1/LicenseService/Licenses/FD00000032890062",
"@odata.type": "#License.v1_1_1.License",
"AuthorizationScope": "Service",
"Description": "iDRAC9 16G Datacenter License",
"DownloadURI": "/redfish/v1/LicenseService/Licenses/FD00000032890062/DownloadURI",
"EntitlementId": "FD00000032890062",
"ExpirationDate": null,
"Id": "FD00000032890062",
"InstallDate": null,
"LicenseInfoURI": "",
"LicenseOrigin": "Installed",
"LicenseType": "Production",
"Links": {},
"Name": "FD00000032890062",
"Removable": true,
"Status": {
"Health": "OK",
"State": "Enabled"
}
}`)
// TestLicense tests the parsing of License objects.
func TestLicense(t *testing.T) {
var result License
err := json.NewDecoder(licenseBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "FD00000032890062", result.ID)
assertEquals(t, "FD00000032890062", result.Name)
assertEquals(t, "Installed", string(result.LicenseOrigin))
assertEquals(t, "true", fmt.Sprintf("%t", result.Removable))
}