Fix nil pointer dereference in TestMultiVA (#6132)

If the test unexpectedly failed, it would hit a nil pointer dereference
on line 511 when it tries to access the `.Type` field of nil. Add another
case to handle this.
This commit is contained in:
Aaron Gable 2022-05-19 17:16:06 -07:00 committed by GitHub
parent 50f6a6b84f
commit 3a94adecb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -504,7 +504,9 @@ func TestMultiVA(t *testing.T) {
res, _ := localVA.PerformValidation(ctx, req)
if res.Problems == nil && tc.ExpectedProb != nil {
t.Errorf("expected prob %v, got nil", tc.ExpectedProb)
} else if res.Problems != nil {
} else if res.Problems != nil && tc.ExpectedProb == nil {
t.Errorf("expected no prob, got %v", res.Problems)
} else if res.Problems != nil && tc.ExpectedProb != nil {
// That result should match expected.
test.AssertEquals(t, res.Problems.ProblemType, string(tc.ExpectedProb.Type))
test.AssertEquals(t, res.Problems.Detail, tc.ExpectedProb.Detail)