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

Function TestTransactionWithDefaultTimeout

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

Source from the content-addressed store, hash-verified

479}
480
481func TestTransactionWithDefaultTimeout(t *testing.T) {
482 db, err := OpenTestConnection(&gorm.Config{DefaultTransactionTimeout: 2 * time.Second})
483 if err != nil {
484 t.Fatalf("failed to connect database, got error %v", err)
485 }
486
487 tx := db.Begin()
488 time.Sleep(3 * time.Second)
489 if err = tx.Find(&User{}).Error; err == nil {
490 t.Errorf("should return error when transaction timeout, got error %v", err)
491 }
492}

Callers

nothing calls this directly

Calls 3

OpenTestConnectionFunction · 0.85
BeginMethod · 0.80
FindMethod · 0.65

Tested by

no test coverage detected