github.com/pyroscope-io/pyroscope@v0.37.3-0.20230725203016-5f6947968bd0/pkg/testing/config.go (about)

     1  package testing
     2  
     3  import (
     4  	"github.com/onsi/ginkgo/v2"
     5  	"github.com/pyroscope-io/pyroscope/pkg/config"
     6  )
     7  
     8  func WithConfig(cb func(cfg **config.Config)) {
     9  	var tmpDir *TmpDirectory
    10  	var cfg *config.Config
    11  
    12  	ginkgo.BeforeEach(func() {
    13  		tmpDir = TmpDirSync()
    14  		cfg = &config.Config{
    15  			Server: config.Server{
    16  				StoragePath: tmpDir.Path,
    17  				APIBindAddr: ":4040",
    18  
    19  				CacheEvictThreshold: 0.02,
    20  				CacheEvictVolume:    0.10,
    21  
    22  				MaxNodesSerialization: 2048,
    23  				MaxNodesRender:        2048,
    24  				Database: config.Database{
    25  					Type: "sqlite3",
    26  				},
    27  
    28  				Auth: config.Auth{
    29  					SignupDefaultRole: "admin",
    30  				},
    31  			},
    32  		}
    33  	})
    34  
    35  	ginkgo.AfterEach(func() {
    36  		tmpDir.Close()
    37  	})
    38  
    39  	cb(&cfg)
    40  }