forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjobservice_test.go
69 lines (59 loc) · 1.58 KB
/
jobservice_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var simpleJobServiceBody = `{
"@odata.context":"/redfish/v1/$metadata#JobService.JobService",
"@odata.etag":"\"1614826331\"",
"@odata.id":"/redfish/v1/JobService",
"@odata.type":"#JobService.v1_0_4.JobService",
"DateTime":"2023-04-25T01:15:32+00:00",
"Description":"Job Service",
"Id":"JobService",
"Name":"Job Service",
"ServiceEnabled":true,
"ServiceCapabilities": {
"Scheduling": true,
"MaxSteps": 50,
"MaxJobs": 50
},
"Status":{
"Health":"OK",
"HealthRollup": "OK",
"State":"Enabled"
},
"Jobs":{
"@odata.id":"/redfish/v1/JobService/Jobs"
},
"Log":{
"@odata.id":"/redfish/v1/JobService/Log"
}
}`
func TestJobService(t *testing.T) {
var result JobService
err := json.NewDecoder(strings.NewReader(simpleJobServiceBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "JobService" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "Job Service" {
t.Errorf("Received invalid name: %s", result.Name)
}
if result.jobs != "/redfish/v1/JobService/Jobs" {
t.Errorf("Received invalid jobs link: %s", result.jobs)
}
if result.log != "/redfish/v1/JobService/Log" {
t.Errorf("Received invalid log link: %s", result.log)
}
if !result.ServiceCapabilities.Scheduling || result.ServiceCapabilities.
MaxJobs != 50 || result.ServiceCapabilities.MaxSteps != 50 {
t.Errorf("Received invalid service capabilities")
}
}