Chore: Update test database initialization (#81673)
* streamline initialization of test databases, support on-disk sqlite test db * clean up test databases * introduce testsuite helper * use testsuite everywhere we use a test db * update documentation * improve error handling * disable entity integration test until we can figure out locking error
This commit is contained in:
@@ -50,9 +50,8 @@ func StartGrafanaEnv(t *testing.T, grafDir, cfgPath string) (string, *server.Tes
|
||||
serverOpts := server.Options{Listener: listener, HomePath: grafDir}
|
||||
apiServerOpts := api.ServerOptions{Listener: listener}
|
||||
|
||||
env, err := server.InitializeForTest(cfg, serverOpts, apiServerOpts)
|
||||
env, err := server.InitializeForTest(t, cfg, serverOpts, apiServerOpts)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, env.SQLStore.Sync())
|
||||
|
||||
require.NotNil(t, env.SQLStore.Cfg)
|
||||
dbSec, err := env.SQLStore.Cfg.Raw.GetSection("database")
|
||||
@@ -99,21 +98,6 @@ func StartGrafanaEnv(t *testing.T, grafDir, cfgPath string) (string, *server.Tes
|
||||
return addr, env
|
||||
}
|
||||
|
||||
// SetUpDatabase sets up the Grafana database.
|
||||
func SetUpDatabase(t *testing.T, grafDir string) *sqlstore.SQLStore {
|
||||
t.Helper()
|
||||
|
||||
sqlStore := db.InitTestDB(t, sqlstore.InitTestDBOpt{
|
||||
EnsureDefaultOrgAndUser: true,
|
||||
})
|
||||
|
||||
// Make sure changes are synced with other goroutines
|
||||
err := sqlStore.Sync()
|
||||
require.NoError(t, err)
|
||||
|
||||
return sqlStore
|
||||
}
|
||||
|
||||
// CreateGrafDir creates the Grafana directory.
|
||||
// The log by default is muted in the regression test, to activate it, pass option EnableLog = true
|
||||
func CreateGrafDir(t *testing.T, opts ...GrafanaOpts) (string, string) {
|
||||
|
||||
Reference in New Issue
Block a user