mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
DRA scheduler: fix potential panic during unit test verification
If there was an unexpected status, the code extracting the expected error message crashed with a panic. Happened once so far, for unknown reasons because the unexpected status then didn't get logged.
This commit is contained in:
parent
bce5886c97
commit
d95d6ba526
@ -1047,7 +1047,9 @@ type testContext struct {
|
|||||||
|
|
||||||
func (tc *testContext) verify(t *testing.T, expected result, initialObjects []metav1.Object, result interface{}, status *framework.Status) {
|
func (tc *testContext) verify(t *testing.T, expected result, initialObjects []metav1.Object, result interface{}, status *framework.Status) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if actualErr := status.AsError(); actualErr != nil {
|
if expected.status == nil {
|
||||||
|
assert.Nil(t, status)
|
||||||
|
} else if actualErr := status.AsError(); actualErr != nil {
|
||||||
// Compare only the error strings.
|
// Compare only the error strings.
|
||||||
assert.ErrorContains(t, actualErr, expected.status.AsError().Error())
|
assert.ErrorContains(t, actualErr, expected.status.AsError().Error())
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user