MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / getAllBlocks

Function getAllBlocks

cmd/cql-fuse/block_test.go:290–312  ·  view source on GitHub ↗
(db *sql.DB, inode uint64)

Source from the content-addressed store, hash-verified

288}
289
290func getAllBlocks(db *sql.DB, inode uint64) ([]byte, error) {
291 blocks, err := getBlocks(db, inode)
292 if err != nil {
293 return nil, err
294 }
295 num := len(blocks)
296 var data []byte
297 for i, b := range blocks {
298 if i != b.block {
299 // We can't have missing blocks.
300 return nil, fmt.Errorf("gap in block list, found block %d at index %d", b.block, i)
301 }
302 bl := uint64(len(b.data))
303 if bl == 0 {
304 return nil, fmt.Errorf("empty block found at %d (out of %d blocks)", i, num)
305 }
306 if i != (num-1) && bl != BlockSize {
307 return nil, fmt.Errorf("non-blocksize %d at %d (out of %d blocks)", bl, i, num)
308 }
309 data = append(data, b.data...)
310 }
311 return data, nil
312}
313
314func TestBlockInfo(t *testing.T) {
315 testCases := []struct {

Callers 3

tryGrowFunction · 0.85
tryShrinkFunction · 0.85
TestReadWriteBlocksFunction · 0.85

Calls 2

getBlocksFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected