Ensure a panic occurs while trying to commit a managed transaction.
(t *testing.T)
| 1066 | |
| 1067 | // Ensure a panic occurs while trying to commit a managed transaction. |
| 1068 | func 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. |
| 1093 | func TestDB_View_ManualRollback(t *testing.T) { |
nothing calls this directly
no test coverage detected