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

Function TestTransactionRaiseErrorOnRollbackAfterCommit

tests/transaction_test.go:165–179  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestTransactionRaiseErrorOnRollbackAfterCommit(t *testing.T) {
166 tx := DB.Begin()
167 user := User{Name: "transaction"}
168 if err := tx.Save(&user).Error; err != nil {
169 t.Fatalf("No error should raise")
170 }
171
172 if err := tx.Commit().Error; err != nil {
173 t.Fatalf("Commit should not raise error")
174 }
175
176 if err := tx.Rollback().Error; err == nil {
177 t.Fatalf("Rollback after commit should raise error")
178 }
179}
180
181func TestTransactionWithSavePoint(t *testing.T) {
182 tx := DB.Begin()

Callers

nothing calls this directly

Calls 4

BeginMethod · 0.80
SaveMethod · 0.80
CommitMethod · 0.65
RollbackMethod · 0.65

Tested by

no test coverage detected