Allow skip migrations in tests via environment variable (#32958)

pull/33108/head
Dafydd 4 years ago committed by GitHub
parent 501d5fbcc2
commit 01150ae962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      pkg/services/sqlstore/sqlstore.go

@ -447,6 +447,15 @@ func InitTestDB(t ITestDB, opts ...InitTestDBOpt) *SQLStore {
}
}
// useful if you already have a database that you want to use for tests.
// cannot just set it on testSQLStore as it overrides the config in Init
if _, present := os.LookupEnv("SKIP_MIGRATIONS"); present {
t.Log("Skipping database migrations")
if _, err := sec.NewKey("skip_migrations", "true"); err != nil {
t.Fatalf("Failed to create key: %s", err)
}
}
// need to get engine to clean db before we init
t.Logf("Creating database connection: %q", sec.Key("connection_string"))
engine, err := xorm.NewEngine(dbType, sec.Key("connection_string").String())

Loading…
Cancel
Save