Update interface_test.go

This commit is contained in:
Skylar Ray 2025-03-11 15:31:54 +02:00 committed by GitHub
parent 6afce8d608
commit 5baf02ee10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -836,12 +836,12 @@ func testMetadataManualTxInterface(tc *testContext) bool {
// testManagedTxPanics ensures calling Rollback of Commit inside a managed // testManagedTxPanics ensures calling Rollback of Commit inside a managed
// transaction panics. // transaction panics.
func testManagedTxPanics(tc *testContext) bool { func testManagedTxPanics(tc *testContext) bool {
testPanic := func(fn func()) (paniced bool) { testPanic := func(fn func()) (panicked bool) {
// Setup a defer to catch the expected panic and update the // Setup a defer to catch the expected panic and update the
// return variable. // return variable.
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
paniced = true panicked = true
} }
}() }()
@ -850,49 +850,49 @@ func testManagedTxPanics(tc *testContext) bool {
} }
// Ensure calling Commit on a managed read-only transaction panics. // Ensure calling Commit on a managed read-only transaction panics.
paniced := testPanic(func() { panicked := testPanic(func() {
tc.db.View(func(tx database.Tx) error { tc.db.View(func(tx database.Tx) error {
tx.Commit() tx.Commit()
return nil return nil
}) })
}) })
if !paniced { if !panicked {
tc.t.Error("Commit called inside View did not panic") tc.t.Error("Commit called inside View did not panic")
return false return false
} }
// Ensure calling Rollback on a managed read-only transaction panics. // Ensure calling Rollback on a managed read-only transaction panics.
paniced = testPanic(func() { panicked = testPanic(func() {
tc.db.View(func(tx database.Tx) error { tc.db.View(func(tx database.Tx) error {
tx.Rollback() tx.Rollback()
return nil return nil
}) })
}) })
if !paniced { if !panicked {
tc.t.Error("Rollback called inside View did not panic") tc.t.Error("Rollback called inside View did not panic")
return false return false
} }
// Ensure calling Commit on a managed read-write transaction panics. // Ensure calling Commit on a managed read-write transaction panics.
paniced = testPanic(func() { panicked = testPanic(func() {
tc.db.Update(func(tx database.Tx) error { tc.db.Update(func(tx database.Tx) error {
tx.Commit() tx.Commit()
return nil return nil
}) })
}) })
if !paniced { if !panicked {
tc.t.Error("Commit called inside Update did not panic") tc.t.Error("Commit called inside Update did not panic")
return false return false
} }
// Ensure calling Rollback on a managed read-write transaction panics. // Ensure calling Rollback on a managed read-write transaction panics.
paniced = testPanic(func() { panicked = testPanic(func() {
tc.db.Update(func(tx database.Tx) error { tc.db.Update(func(tx database.Tx) error {
tx.Rollback() tx.Rollback()
return nil return nil
}) })
}) })
if !paniced { if !panicked {
tc.t.Error("Rollback called inside Update did not panic") tc.t.Error("Rollback called inside Update did not panic")
return false return false
} }