summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'integrations')
-rw-r--r--integrations/integration_test.go26
-rw-r--r--integrations/lfs_getobject_test.go2
-rw-r--r--integrations/migration-test/migration_test.go48
3 files changed, 38 insertions, 38 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index eaec2d509e..e4d506ee7d 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -59,13 +59,13 @@ func TestMain(m *testing.M) {
routes.RegisterRoutes(mac)
var helper testfixtures.Helper
- if setting.UseMySQL {
+ if setting.Database.UseMySQL {
helper = &testfixtures.MySQL{}
- } else if setting.UsePostgreSQL {
+ } else if setting.Database.UsePostgreSQL {
helper = &testfixtures.PostgreSQL{}
- } else if setting.UseSQLite3 {
+ } else if setting.Database.UseSQLite3 {
helper = &testfixtures.SQLite{}
- } else if setting.UseMSSQL {
+ } else if setting.Database.UseMSSQL {
helper = &testfixtures.SQLServer{}
} else {
fmt.Println("Unsupported RDBMS for integration tests")
@@ -121,12 +121,12 @@ func initIntegrationTest() {
setting.SetCustomPathAndConf("", "", "")
setting.NewContext()
setting.CheckLFSVersion()
- models.LoadConfigs()
+ setting.InitDBConfig()
switch {
- case setting.UseMySQL:
+ case setting.Database.UseMySQL:
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host))
defer db.Close()
if err != nil {
log.Fatalf("sql.Open: %v", err)
@@ -134,14 +134,14 @@ func initIntegrationTest() {
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
}
- case setting.UsePostgreSQL:
+ case setting.Database.UsePostgreSQL:
db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host, models.DbCfg.SSLMode))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode))
defer db.Close()
if err != nil {
log.Fatalf("sql.Open: %v", err)
}
- rows, err := db.Query(fmt.Sprintf("SELECT 1 FROM pg_database WHERE datname = '%s'", models.DbCfg.Name))
+ rows, err := db.Query(fmt.Sprintf("SELECT 1 FROM pg_database WHERE datname = '%s'", setting.Database.Name))
if err != nil {
log.Fatalf("db.Query: %v", err)
}
@@ -153,10 +153,10 @@ func initIntegrationTest() {
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
}
- case setting.UseMSSQL:
- host, port := models.ParseMSSQLHostPort(models.DbCfg.Host)
+ case setting.Database.UseMSSQL:
+ host, port := setting.ParseMSSQLHostPort(setting.Database.Host)
db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
- host, port, "master", models.DbCfg.User, models.DbCfg.Passwd))
+ host, port, "master", setting.Database.User, setting.Database.Passwd))
if err != nil {
log.Fatalf("sql.Open: %v", err)
}
diff --git a/integrations/lfs_getobject_test.go b/integrations/lfs_getobject_test.go
index 42b64612fd..bb269d5eeb 100644
--- a/integrations/lfs_getobject_test.go
+++ b/integrations/lfs_getobject_test.go
@@ -39,7 +39,7 @@ func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string
assert.NoError(t, err)
var lfsMetaObject *models.LFSMetaObject
- if setting.UsePostgreSQL {
+ if setting.Database.UsePostgreSQL {
lfsMetaObject = &models.LFSMetaObject{ID: lfsID, Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID}
} else {
lfsMetaObject = &models.LFSMetaObject{Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID}
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go
index 858f339b89..3b47f0d7fc 100644
--- a/integrations/migration-test/migration_test.go
+++ b/integrations/migration-test/migration_test.go
@@ -54,7 +54,7 @@ func initMigrationTest(t *testing.T) {
setting.NewContext()
setting.CheckLFSVersion()
- models.LoadConfigs()
+ setting.InitDBConfig()
setting.NewLogServices(true)
}
@@ -64,7 +64,7 @@ func availableVersions() ([]string, error) {
return nil, err
}
defer migrationsDir.Close()
- versionRE, err := regexp.Compile("gitea-v(?P<version>.+)\\." + regexp.QuoteMeta(models.DbCfg.Type) + "\\.sql.gz")
+ versionRE, err := regexp.Compile("gitea-v(?P<version>.+)\\." + regexp.QuoteMeta(setting.Database.Type) + "\\.sql.gz")
if err != nil {
return nil, err
}
@@ -85,7 +85,7 @@ func availableVersions() ([]string, error) {
}
func readSQLFromFile(version string) (string, error) {
- filename := fmt.Sprintf("integrations/migration-test/gitea-v%s.%s.sql.gz", version, models.DbCfg.Type)
+ filename := fmt.Sprintf("integrations/migration-test/gitea-v%s.%s.sql.gz", version, setting.Database.Type)
if _, err := os.Stat(filename); os.IsNotExist(err) {
return "", nil
@@ -114,17 +114,17 @@ func restoreOldDB(t *testing.T, version string) bool {
data, err := readSQLFromFile(version)
assert.NoError(t, err)
if len(data) == 0 {
- integrations.Printf("No db found to restore for %s version: %s\n", models.DbCfg.Type, version)
+ integrations.Printf("No db found to restore for %s version: %s\n", setting.Database.Type, version)
return false
}
switch {
- case setting.UseSQLite3:
- os.Remove(models.DbCfg.Path)
- err := os.MkdirAll(path.Dir(models.DbCfg.Path), os.ModePerm)
+ case setting.Database.UseSQLite3:
+ os.Remove(setting.Database.Path)
+ err := os.MkdirAll(path.Dir(setting.Database.Path), os.ModePerm)
assert.NoError(t, err)
- db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d", models.DbCfg.Path, models.DbCfg.Timeout))
+ db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?cache=shared&mode=rwc&_busy_timeout=%d", setting.Database.Path, setting.Database.Timeout))
assert.NoError(t, err)
defer db.Close()
@@ -132,20 +132,20 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.UseMySQL:
+ case setting.Database.UseMySQL:
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host))
assert.NoError(t, err)
defer db.Close()
- _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", models.DbCfg.Name))
+ _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", setting.Database.Name))
assert.NoError(t, err)
- _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", models.DbCfg.Name))
+ _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", setting.Database.Name))
assert.NoError(t, err)
db, err = sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?multiStatements=true",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host, models.DbCfg.Name))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name))
assert.NoError(t, err)
defer db.Close()
@@ -153,21 +153,21 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.UsePostgreSQL:
+ case setting.Database.UsePostgreSQL:
db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host, models.DbCfg.SSLMode))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode))
assert.NoError(t, err)
defer db.Close()
- _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", models.DbCfg.Name))
+ _, err = db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS %s", setting.Database.Name))
assert.NoError(t, err)
- _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s", models.DbCfg.Name))
+ _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s", setting.Database.Name))
assert.NoError(t, err)
db.Close()
db, err = sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s",
- models.DbCfg.User, models.DbCfg.Passwd, models.DbCfg.Host, models.DbCfg.Name, models.DbCfg.SSLMode))
+ setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.Name, setting.Database.SSLMode))
assert.NoError(t, err)
defer db.Close()
@@ -175,10 +175,10 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.UseMSSQL:
- host, port := models.ParseMSSQLHostPort(models.DbCfg.Host)
+ case setting.Database.UseMSSQL:
+ host, port := setting.ParseMSSQLHostPort(setting.Database.Host)
db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
- host, port, "master", models.DbCfg.User, models.DbCfg.Passwd))
+ host, port, "master", setting.Database.User, setting.Database.Passwd))
assert.NoError(t, err)
defer db.Close()
@@ -191,7 +191,7 @@ func restoreOldDB(t *testing.T, version string) bool {
dbname := statement[5 : len(statement)-1]
db.Close()
db, err = sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
- host, port, dbname, models.DbCfg.User, models.DbCfg.Passwd))
+ host, port, dbname, setting.Database.User, setting.Database.Passwd))
assert.NoError(t, err)
defer db.Close()
}
@@ -210,7 +210,7 @@ func wrappedMigrate(x *xorm.Engine) error {
func doMigrationTest(t *testing.T, version string) {
integrations.PrintCurrentTest(t)
- integrations.Printf("Performing migration test for %s version: %s\n", models.DbCfg.Type, version)
+ integrations.Printf("Performing migration test for %s version: %s\n", setting.Database.Type, version)
if !restoreOldDB(t, version) {
return
}
@@ -227,7 +227,7 @@ func doMigrationTest(t *testing.T, version string) {
func TestMigrations(t *testing.T) {
initMigrationTest(t)
- dialect := models.DbCfg.Type
+ dialect := setting.Database.Type
versions, err := availableVersions()
assert.NoError(t, err)