Skip to content

Commit 165dd98

Browse files
authored
Add tests for afterinsert (go-xorm#755)
* add tests for afterinsert * fix tests
1 parent fbf62a9 commit 165dd98

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

processors_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,3 +1029,22 @@ func TestAfterLoadProcessor(t *testing.T) {
10291029
assert.NoError(t, bs[i].Err)
10301030
}
10311031
}
1032+
1033+
type AfterInsertStruct struct {
1034+
Id int64
1035+
}
1036+
1037+
func (a *AfterInsertStruct) AfterInsert() {
1038+
if a.Id == 0 {
1039+
panic("a.Id")
1040+
}
1041+
}
1042+
1043+
func TestAfterInsert(t *testing.T) {
1044+
assert.NoError(t, prepareEngine())
1045+
1046+
assertSync(t, new(AfterInsertStruct))
1047+
1048+
_, err := testEngine.Insert(&AfterInsertStruct{})
1049+
assert.NoError(t, err)
1050+
}

0 commit comments

Comments
 (0)