MCPcopy
hub / github.com/etcd-io/bbolt / TestDB_Update_ManualCommit

Function TestDB_Update_ManualCommit

db_test.go:1018–1040  ·  view source on GitHub ↗

Ensure a panic occurs while trying to commit a managed transaction.

(t *testing.T)

Source from the content-addressed store, hash-verified

1016
1017// Ensure a panic occurs while trying to commit a managed transaction.
1018func TestDB_Update_ManualCommit(t *testing.T) {
1019 db := btesting.MustCreateDB(t)
1020
1021 var panicked bool
1022 if err := db.Update(func(tx *bolt.Tx) error {
1023 func() {
1024 defer func() {
1025 if r := recover(); r != nil {
1026 panicked = true
1027 }
1028 }()
1029
1030 if err := tx.Commit(); err != nil {
1031 t.Fatal(err)
1032 }
1033 }()
1034 return nil
1035 }); err != nil {
1036 t.Fatal(err)
1037 } else if !panicked {
1038 t.Fatal("expected panic")
1039 }
1040}
1041
1042// Ensure a panic occurs while trying to rollback a managed transaction.
1043func TestDB_Update_ManualRollback(t *testing.T) {

Callers

nothing calls this directly

Calls 4

MustCreateDBFunction · 0.92
UpdateMethod · 0.80
CommitMethod · 0.80
FatalMethod · 0.65

Tested by

no test coverage detected