MCPcopy
hub / github.com/go-gorm/gorm / TestPreparedStmtInTransaction

Function TestPreparedStmtInTransaction

tests/prepared_stmt_test.go:188–202  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestPreparedStmtInTransaction(t *testing.T) {
189 user := User{Name: "jinzhu"}
190
191 if err := DB.Transaction(func(tx *gorm.DB) error {
192 tx.Session(&gorm.Session{PrepareStmt: true}).Create(&user)
193 return errors.New("test")
194 }); err == nil {
195 t.Error(err)
196 }
197
198 var result User
199 if err := DB.First(&result, user.ID).Error; err == nil {
200 t.Errorf("Failed, got error: %v", err)
201 }
202}
203
204func TestPreparedStmtClose(t *testing.T) {
205 tx := DB.Session(&gorm.Session{PrepareStmt: true})

Callers

nothing calls this directly

Calls 6

TransactionMethod · 0.80
SessionMethod · 0.80
CreateMethod · 0.65
NewMethod · 0.65
ErrorMethod · 0.65
FirstMethod · 0.65

Tested by

no test coverage detected