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

Function TestDB_View_ManualCommit

db_test.go:1068–1090  ·  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

1066
1067// Ensure a panic occurs while trying to commit a managed transaction.
1068func TestDB_View_ManualCommit(t *testing.T) {
1069 db := btesting.MustCreateDB(t)
1070
1071 var panicked bool
1072 if err := db.View(func(tx *bolt.Tx) error {
1073 func() {
1074 defer func() {
1075 if r := recover(); r != nil {
1076 panicked = true
1077 }
1078 }()
1079
1080 if err := tx.Commit(); err != nil {
1081 t.Fatal(err)
1082 }
1083 }()
1084 return nil
1085 }); err != nil {
1086 t.Fatal(err)
1087 } else if !panicked {
1088 t.Fatal("expected panic")
1089 }
1090}
1091
1092// Ensure a panic occurs while trying to rollback a managed transaction.
1093func TestDB_View_ManualRollback(t *testing.T) {

Callers

nothing calls this directly

Calls 4

MustCreateDBFunction · 0.92
ViewMethod · 0.80
CommitMethod · 0.80
FatalMethod · 0.65

Tested by

no test coverage detected