// Ensure a closed database returns an error while running a transaction block func TestDB_Update_Closed(t *testing.T) { var db bolt.DB err := db.Update(func(tx *bolt.Tx) error { tx.CreateBucket([]byte("widgets")) return nil }) equals(t, err, bolt.ErrDatabaseNotOpen) }
func deleteKey(db *bolt.DB, name string) error { return db.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(dbBucket)) if b == nil { return fmt.Errorf("unknown bucket: %v", dbBucket) } return b.Delete([]byte(name)) }) }
func setMigrated(db *bolt.DB, name string) error { return db.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(dbBucket)) if b == nil { return fmt.Errorf("unknown bucket: %v", dbBucket) } return b.Put([]byte("isMigrated:"+name), []byte{1}) }) }
func deleteKey(db *bolt.DB, name string) error { return db.Update(func(tx *bolt.Tx) error { b := tx.Bucket([]byte(dbBucket)) return b.Delete([]byte(name)) }) }