prepareBuckets opens the bucket chain. For each bucket in the chain, open it if existed, otherwise create it and populate sample data.
(t testing.TB, tx *bbolt.Tx, buckets ...string)
| 342 | // prepareBuckets opens the bucket chain. For each bucket in the chain, |
| 343 | // open it if existed, otherwise create it and populate sample data. |
| 344 | func prepareBuckets(t testing.TB, tx *bbolt.Tx, buckets ...string) *bbolt.Bucket { |
| 345 | var bk *bbolt.Bucket |
| 346 | |
| 347 | for _, key := range buckets { |
| 348 | if childBucket := openBucket(tx, bk, key); childBucket == nil { |
| 349 | bk = createBucketAndPopulateData(t, tx, bk, key) |
| 350 | } else { |
| 351 | bk = childBucket |
| 352 | } |
| 353 | } |
| 354 | return bk |
| 355 | } |
| 356 | |
| 357 | func openBucket(tx *bbolt.Tx, bk *bbolt.Bucket, bucketToOpen string) *bbolt.Bucket { |
| 358 | if bk == nil { |
no test coverage detected