Explorar o código

Add tests for afterinsert

xormplus %!s(int64=8) %!d(string=hai) anos
pai
achega
b91af28992
Modificáronse 1 ficheiros con 19 adicións e 0 borrados
  1. 19 0
      processors_test.go

+ 19 - 0
processors_test.go

@@ -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)
+}