mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-13 11:35:52 +01:00
Update interface_test.go
This commit is contained in:
parent
6afce8d608
commit
5baf02ee10
1 changed files with 10 additions and 10 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue