diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-11-01 04:51:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 16:51:48 -0400 |
commit | e4e85a3e51066f4987a87762c9c69acda093f6ca (patch) | |
tree | 14c00ee9e19dcec4ac2a93e6b5a0f0ec343f824c /integrations/integration_test.go | |
parent | e7750e0f6a4fb032bb0f717caf2b8a10a6ede873 (diff) | |
download | gitea-e4e85a3e51066f4987a87762c9c69acda093f6ca.tar.gz gitea-e4e85a3e51066f4987a87762c9c69acda093f6ca.zip |
Storage configuration support `[storage]` (#13314)
* Fix minio bug
* Add tests for storage configuration
* Change the Seek flag to keep compitable minio?
* Fix test when first-byte-pos of all ranges is greater than the resource length
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'integrations/integration_test.go')
-rw-r--r-- | integrations/integration_test.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go index 3942d54410..13a1bac370 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -11,7 +11,6 @@ import ( "encoding/json" "fmt" "io" - "log" "net/http" "net/http/cookiejar" "net/http/httptest" @@ -27,8 +26,10 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/graceful" + "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/queue" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers" "code.gitea.io/gitea/routers/routes" @@ -59,6 +60,8 @@ func NewNilResponseRecorder() *NilResponseRecorder { } func TestMain(m *testing.M) { + defer log.Close() + managerCtx, cancel := context.WithCancel(context.Background()) graceful.InitManager(managerCtx) defer cancel() @@ -142,6 +145,10 @@ func initIntegrationTest() { util.RemoveAll(models.LocalCopyPath()) setting.CheckLFSVersion() setting.InitDBConfig() + if err := storage.Init(); err != nil { + fmt.Printf("Init storage failed: %v", err) + os.Exit(1) + } switch { case setting.Database.UseMySQL: @@ -149,27 +156,27 @@ func initIntegrationTest() { setting.Database.User, setting.Database.Passwd, setting.Database.Host)) defer db.Close() if err != nil { - log.Fatalf("sql.Open: %v", err) + log.Fatal("sql.Open: %v", err) } if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", setting.Database.Name)); err != nil { - log.Fatalf("db.Exec: %v", err) + log.Fatal("db.Exec: %v", err) } case setting.Database.UsePostgreSQL: db, err := sql.Open("postgres", fmt.Sprintf("postgres://%s:%s@%s/?sslmode=%s", setting.Database.User, setting.Database.Passwd, setting.Database.Host, setting.Database.SSLMode)) defer db.Close() if err != nil { - log.Fatalf("sql.Open: %v", err) + log.Fatal("sql.Open: %v", err) } dbrows, 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) + log.Fatal("db.Query: %v", err) } defer dbrows.Close() if !dbrows.Next() { if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s", setting.Database.Name)); err != nil { - log.Fatalf("db.Exec: CREATE DATABASE: %v", err) + log.Fatal("db.Exec: CREATE DATABASE: %v", err) } } // Check if we need to setup a specific schema @@ -183,18 +190,18 @@ func initIntegrationTest() { // This is a different db object; requires a different Close() defer db.Close() if err != nil { - log.Fatalf("sql.Open: %v", err) + log.Fatal("sql.Open: %v", err) } schrows, err := db.Query(fmt.Sprintf("SELECT 1 FROM information_schema.schemata WHERE schema_name = '%s'", setting.Database.Schema)) if err != nil { - log.Fatalf("db.Query: %v", err) + log.Fatal("db.Query: %v", err) } defer schrows.Close() if !schrows.Next() { // Create and setup a DB schema if _, err = db.Exec(fmt.Sprintf("CREATE SCHEMA %s", setting.Database.Schema)); err != nil { - log.Fatalf("db.Exec: CREATE SCHEMA: %v", err) + log.Fatal("db.Exec: CREATE SCHEMA: %v", err) } } @@ -203,10 +210,10 @@ func initIntegrationTest() { db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", host, port, "master", setting.Database.User, setting.Database.Passwd)) if err != nil { - log.Fatalf("sql.Open: %v", err) + log.Fatal("sql.Open: %v", err) } if _, err := db.Exec(fmt.Sprintf("If(db_id(N'%s') IS NULL) BEGIN CREATE DATABASE %s; END;", setting.Database.Name, setting.Database.Name)); err != nil { - log.Fatalf("db.Exec: %v", err) + log.Fatal("db.Exec: %v", err) } defer db.Close() } |