Repository navigation
test: address MaxPowerWatts review comments from #55 #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,8 +193,10 @@ func TestChassis(t *testing.T) { | |
| t.Errorf("Received invalid chassis type: %s", result.ChassisType) | ||
| } | ||
|
|
||
| if result.MaxPowerWatts == nil || *result.MaxPowerWatts != 1200 { | ||
| t.Errorf("Received invalid max power watts: %v", result.MaxPowerWatts) | ||
| if result.MaxPowerWatts == nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not blocking: It has the same missing-vs-zero problem that this PR tests for Please change |
||
| t.Error("Expected max power watts to be set") | ||
| } else if *result.MaxPowerWatts != 1200 { | ||
| t.Errorf("Received invalid max power watts: %v", *result.MaxPowerWatts) | ||
| } | ||
|
|
||
| if result.Status.Health != common.OKHealth { | ||
|
|
@@ -296,6 +298,21 @@ func TestMinimumChassis(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| // TestChassisZeroMaxPowerWatts ensures a reported 0 is distinguishable from absent. | ||
| func TestChassisZeroMaxPowerWatts(t *testing.T) { | ||
| var result Chassis | ||
| err := json.NewDecoder(strings.NewReader(`{"Id": "1", "MaxPowerWatts": 0}`)).Decode(&result) | ||
|
Comment on lines
+301
to
+304
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: This test checks only the reported-0 case, and no test covers The doc comment says 0 is distinguishable from absent, but the absent check lives in The schema also types the field as Please make this a small table with absent, |
||
| if err != nil { | ||
| t.Fatalf("Error decoding JSON: %s", err) | ||
| } | ||
|
|
||
| if result.MaxPowerWatts == nil { | ||
| t.Error("Expected max power watts to be set when reported as 0") | ||
| } else if *result.MaxPowerWatts != 0 { | ||
| t.Errorf("Received invalid max power watts: %v", *result.MaxPowerWatts) | ||
| } | ||
| } | ||
|
|
||
| // TestLinkedDriveChassis tests getting drives from versions supporting the older | ||
| // Chassis.Links.Drives location. | ||
| func TestLinkedDriveChassis(t *testing.T) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The setup steps in this test report errors with
t.Errorfand keep going, so a setup failure panics before it reaches this check.If the fixture stops decoding,
FromChassisreturnsnil, err(oem/smc/chassis_test.go:94), andresult.IDat line 97 panics with a nil dereference. The decode check at oem/smc/chassis_test.go:89 has the same problem. The new redfish test in this PR usest.Fatalffor the same step.Please switch both setup checks to
t.Fatalf.