(t *testing.T)
| 430 | } |
| 431 | |
| 432 | func TestTransactionOnClosedConn(t *testing.T) { |
| 433 | DB, err := OpenTestConnection(&gorm.Config{}) |
| 434 | if err != nil { |
| 435 | t.Fatalf("failed to connect database, got error %v", err) |
| 436 | } |
| 437 | rawDB, _ := DB.DB() |
| 438 | rawDB.Close() |
| 439 | |
| 440 | if err := DB.Transaction(func(tx *gorm.DB) error { |
| 441 | return nil |
| 442 | }); err == nil { |
| 443 | t.Errorf("should returns error when commit with closed conn, got error %v", err) |
| 444 | } |
| 445 | |
| 446 | if err := DB.Session(&gorm.Session{PrepareStmt: true}).Transaction(func(tx *gorm.DB) error { |
| 447 | return nil |
| 448 | }); err == nil { |
| 449 | t.Errorf("should returns error when commit with closed conn, got error %v", err) |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | func TestTransactionWithHooks(t *testing.T) { |
| 454 | user := GetUser("tTestTransactionWithHooks", Config{Account: true}) |
nothing calls this directly
no test coverage detected