add tests for last error

This commit is contained in:
Lunny Xiao 2019-01-20 11:19:43 +08:00
parent 85f31aba0d
commit 851aa49505
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 19 additions and 1 deletions

View File

@ -1331,3 +1331,21 @@ func TestUpdateCondiBean(t *testing.T) {
assert.NoError(t, err)
assert.True(t, has)
}
func TestWhereCondErrorWhenUpdate(t *testing.T) {
type AuthRequestError struct {
ChallengeToken string
RequestToken string
}
assert.NoError(t, prepareEngine())
assertSync(t, new(AuthRequestError))
_, err := testEngine.Cols("challenge_token", "request_token", "challenge_agent", "status").
Where(&AuthRequestError{ChallengeToken: "1"}).
Update(&AuthRequestError{
ChallengeToken: "2",
})
assert.Error(t, err)
assert.EqualValues(t, ErrConditionType, err)
}

View File

@ -162,7 +162,7 @@ func (statement *Statement) And(query interface{}, args ...interface{}) *Stateme
}
}
default:
statement.lastError = errors.New("unsupported condition type")
statement.lastError = ErrConditionType
}
return statement