github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/storage/util/testing.go (about)

     1  package util
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"testing"
     7  
     8  	"github.com/dgraph-io/badger/v2"
     9  	"github.com/stretchr/testify/require"
    10  
    11  	"github.com/onflow/flow-go/module/metrics"
    12  	"github.com/onflow/flow-go/storage"
    13  	bstorage "github.com/onflow/flow-go/storage/badger"
    14  )
    15  
    16  func StorageLayer(_ testing.TB, db *badger.DB) *storage.All {
    17  	metrics := metrics.NewNoopCollector()
    18  	all := bstorage.InitAll(metrics, db)
    19  	return all
    20  }
    21  
    22  func CreateFiles(t *testing.T, dir string, names ...string) {
    23  	for _, name := range names {
    24  		file, err := os.Create(filepath.Join(dir, name))
    25  		require.NoError(t, err)
    26  		err = file.Close()
    27  		require.NoError(t, err)
    28  	}
    29  }