-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some linked objects were not defined right. Fixed that and added unit test coverage based on a real system. Signed-off-by: Sean McGinnis <[email protected]>
- Loading branch information
1 parent
80de948
commit 6d550fa
Showing
4 changed files
with
95 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
package redfish | ||
|
||
import ( | ||
"encoding/json" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
var thermalSubsystemBody = `{ | ||
"@odata.context": "/redfish/v1/$metadata#ThermalSubsystem.ThermalSubsystem", | ||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/ThermalSubsystem", | ||
"@odata.type": "#ThermalSubsystem.v1_2_0.ThermalSubsystem", | ||
"Description": "Represents the properties of a Thermal Subsystem of the Chassis", | ||
"Name": "Thermal Subsystem for Chassis", | ||
"FanRedundancy": [ | ||
{ | ||
"RedundancyType": "NPlusM", | ||
"MaxSupportedInGroup": null, | ||
"MinNeededInGroup": null, | ||
"RedundancyGroup": [], | ||
"[email protected]": 0, | ||
"Status": { | ||
"State": "Enabled", | ||
"Health": "OK" | ||
} | ||
} | ||
], | ||
"Fans": { | ||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/ThermalSubsystem/Fans" | ||
}, | ||
"ThermalMetrics": { | ||
"@odata.id": "/redfish/v1/Chassis/System.Embedded.1/ThermalSubsystem/ThermalMetrics" | ||
}, | ||
"Status": { | ||
"State": "Enabled", | ||
"Health": "OK" | ||
}, | ||
"Id": "ThermalSubsystem" | ||
}` | ||
|
||
// TestThermalSubsystem tests the parsing of ThermalSubsystem objects. | ||
func TestThermalSubsystem(t *testing.T) { | ||
var result ThermalSubsystem | ||
err := json.NewDecoder(strings.NewReader(thermalSubsystemBody)).Decode(&result) | ||
|
||
if err != nil { | ||
t.Errorf("Error decoding JSON: %s", err) | ||
} | ||
|
||
if result.ID != "ThermalSubsystem" { | ||
t.Errorf("Received invalid ID: %s", result.ID) | ||
} | ||
|
||
if result.Name != "Thermal Subsystem for Chassis" { | ||
t.Errorf("Received invalid name: %s", result.Name) | ||
} | ||
|
||
if result.fans != "/redfish/v1/Chassis/System.Embedded.1/ThermalSubsystem/Fans" { | ||
t.Errorf("Invalid fans link: %s", result.fans) | ||
} | ||
} |