Add tests for afterinsert (#755)

* add tests for afterinsert

* fix tests
This commit is contained in:
Lunny Xiao 2017-10-24 16:44:00 +08:00 committed by GitHub
parent fbf62a9711
commit 165dd989d0
1 changed files with 19 additions and 0 deletions

View File

@ -1029,3 +1029,22 @@ func TestAfterLoadProcessor(t *testing.T) {
assert.NoError(t, bs[i].Err)
}
}
type AfterInsertStruct struct {
Id int64
}
func (a *AfterInsertStruct) AfterInsert() {
if a.Id == 0 {
panic("a.Id")
}
}
func TestAfterInsert(t *testing.T) {
assert.NoError(t, prepareEngine())
assertSync(t, new(AfterInsertStruct))
_, err := testEngine.Insert(&AfterInsertStruct{})
assert.NoError(t, err)
}