forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccelerationfunction_test.go
52 lines (45 loc) · 1.3 KB
/
accelerationfunction_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var accelerationFunctionBody = strings.NewReader(
`{
"@odata.type": "#AccelerationFunction.v1_0_4.AccelerationFunction",
"Id": "Compression",
"Name": "Compression Accelerator",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"FpgaReconfigurationSlots": [
"AFU0"
],
"AccelerationFunctionType": "Compression",
"Manufacturer": "Intel (R) Corporation",
"Version": "Green Compression Type 1 v.1.00.86",
"PowerWatts": 15,
"Links": {
"Endpoints": [],
"PCIeFunctions": []
},
"@odata.id": "/redfish/v1/Systems/1/Processors/FPGA1/AccelerationFunctions/Compression"
}`)
// TestAccerlationFunction tests the parsing of AccerlationFunction objects.
func TestAccerlationFunction(t *testing.T) {
var result AccelerationFunction
err := json.NewDecoder(accelerationFunctionBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "Compression", result.ID)
assertEquals(t, "Compression Accelerator", result.Name)
assertEquals(t, "Compression", string(result.AccelerationFunctionType))
if len(result.FPGAReconfigurationSlots) != 1 {
t.Errorf("Expected 1 FPGA reconfiguration slots, got %#v", result.FPGAReconfigurationSlots)
}
}