test: topologymanager: handle panic in test

unexpected success should cause a test failure, not a panic

Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
Francesco Romani
2025-10-15 12:16:32 +02:00
parent 00a8ddce91
commit cccb66bfbc

View File

@@ -154,7 +154,9 @@ func TestNewTopologyManagerOptions(t *testing.T) {
}
opts, err := NewPolicyOptions(logger, tcase.policyOptions)
if tcase.expectedErr != nil {
if !strings.Contains(err.Error(), tcase.expectedErr.Error()) {
if err == nil {
t.Errorf("expected error %v, got no error", tcase.expectedErr)
} else if !strings.Contains(err.Error(), tcase.expectedErr.Error()) {
t.Errorf("Unexpected error message. Have: %s, wants %s", err.Error(), tcase.expectedErr.Error())
}
return