Пример #1
0
func (suite *CounterTestSuite) SetupTest() {
	var err error
	suite.tx, err = suite.db.Begin(true)
	suite.NoError(err, "begin transation")

	suite.bucket, err = suite.tx.CreateBucket([]byte("test"))
	suite.NoError(err, "create initial bucket")

	suite.NoError(defaults.InitializeBucket(suite.bucket))
}
Пример #2
0
// CreateScope creates a scope, i.e. for _global or #channel.
func (b *BotDB) CreateScope(scope string) error {
	return b.db.Batch(func(tx *bolt.Tx) error {
		bucket, err := helpers.CreateBucketIfNotExistsWrap(tx, []byte(scope))
		if err != nil {
			return err
		}

		return defaults.InitializeBucket(bucket)
	})
}