export_test.go raw

   1  /*This test file is part of the ffldb package rather than than the ffldb_test package so it can bridge access to the internals to properly test cases which are either not possible or can't reliably be tested via the public interface. The functions are only exported while the tests are being run.
   2   */
   3  
   4  package ffldb
   5  
   6  import (
   7  	"github.com/p9c/p9/pkg/database"
   8  )
   9  
  10  // TstRunWithMaxBlockFileSize runs the passed function with the maximum allowed file size for the database set to the
  11  // provided value. The value will be set back to the original value upon completion.
  12  func TstRunWithMaxBlockFileSize(idb database.DB, size uint32, fn func()) {
  13  	ffldb := idb.(*db)
  14  	origSize := ffldb.store.maxBlockFileSize
  15  	ffldb.store.maxBlockFileSize = size
  16  	fn()
  17  	ffldb.store.maxBlockFileSize = origSize
  18  }
  19