Ensure that looping over a bucket on a closed database returns an error.
(t *testing.T)
| 1146 | |
| 1147 | // Ensure that looping over a bucket on a closed database returns an error. |
| 1148 | func TestBucket_ForEach_Closed(t *testing.T) { |
| 1149 | db := btesting.MustCreateDB(t) |
| 1150 | |
| 1151 | tx, err := db.Begin(true) |
| 1152 | if err != nil { |
| 1153 | t.Fatal(err) |
| 1154 | } |
| 1155 | |
| 1156 | b, err := tx.CreateBucket([]byte("widgets")) |
| 1157 | if err != nil { |
| 1158 | t.Fatal(err) |
| 1159 | } |
| 1160 | |
| 1161 | if err := tx.Rollback(); err != nil { |
| 1162 | t.Fatal(err) |
| 1163 | } |
| 1164 | |
| 1165 | if err := b.ForEach(func(k, v []byte) error { return nil }); err != berrors.ErrTxClosed { |
| 1166 | t.Fatalf("unexpected error: %s", err) |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | // Ensure that an error is returned when inserting with an empty key. |
| 1171 | func TestBucket_Put_EmptyKey(t *testing.T) { |
nothing calls this directly
no test coverage detected