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

Function TestDB_View_Error

db_test.go:1161–1169  ·  view source on GitHub ↗

Ensure a database can return an error through a read-only transactional block.

(t *testing.T)

Source from the content-addressed store, hash-verified

1159
1160// Ensure a database can return an error through a read-only transactional block.
1161func TestDB_View_Error(t *testing.T) {
1162 db := btesting.MustCreateDB(t)
1163
1164 if err := db.View(func(tx *bolt.Tx) error {
1165 return errors.New("xxx")
1166 }); err == nil || err.Error() != "xxx" {
1167 t.Fatalf("unexpected error: %s", err)
1168 }
1169}
1170
1171// Ensure a read transaction that panics does not hold open locks.
1172func TestDB_View_Panic(t *testing.T) {

Callers

nothing calls this directly

Calls 4

MustCreateDBFunction · 0.92
ViewMethod · 0.80
ErrorMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected