rpcserver: Update error case handling in tests.

This updates the rpcserver handler tests to properly call Errorf in the
case that the test specifies wantErr, but err is nil.
This commit is contained in:
Ryan Staudt 2020-07-13 15:02:00 -05:00 committed by Dave Collins
parent 58b094f0fa
commit faec0f8280

View File

@ -3370,7 +3370,11 @@ func testRPCServerHandler(t *testing.T, tests []rpcTest) {
if test.wantErr {
var rpcErr *dcrjson.RPCError
if !errors.As(err, &rpcErr) || rpcErr.Code != test.errCode {
t.Errorf("%s\nwant: %+v\n got: %+v\n", test.name, test.errCode, rpcErr.Code)
if rpcErr != nil {
t.Errorf("%s\nwant: %+v\n got: %+v\n", test.name, test.errCode, rpcErr.Code)
} else {
t.Errorf("%s\nwant: %+v\n got: nil\n", test.name, test.errCode)
}
}
return
}