diff options
author | zeripath <art27@cantab.net> | 2019-04-07 01:25:14 +0100 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-04-07 03:25:14 +0300 |
commit | 5422f23ed8174661b6e658250e4007b7fdf0d603 (patch) | |
tree | 87d975854be55c51e0a51c49cf93c33e310d30da /integrations/migration-test/migration_test.go | |
parent | 7ed65a98e80a341885b8cddce971012b7fcdae4e (diff) | |
download | gitea-5422f23ed8174661b6e658250e4007b7fdf0d603.tar.gz gitea-5422f23ed8174661b6e658250e4007b7fdf0d603.zip |
Quieter Integration Tests (#6513)
* Rename BaseLogger to WriterLogger to help the creation of other providers
* Don't export ColorBytes and ResetBytes from ColoredValues
* Make integration tests only print logs if they fail
* check can color before coloring
* I always forget about MSSQL
* Oh and use LEVEL in sqlite.ini
* Make the test logger log at info - as it means you see the router
* Remove empty expected changes
* Make the migrations quieter too
* Don't display SQL on error - it can be looked at in the file logs if necessary
* Fix skip when using onGiteaRun
Diffstat (limited to 'integrations/migration-test/migration_test.go')
-rw-r--r-- | integrations/migration-test/migration_test.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go index 6fd7af832e..93b60e0e31 100644 --- a/integrations/migration-test/migration_test.go +++ b/integrations/migration-test/migration_test.go @@ -9,13 +9,13 @@ import ( "database/sql" "fmt" "io/ioutil" - "log" "os" "path" "regexp" "sort" "testing" + "code.gitea.io/gitea/integrations" "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/migrations" "code.gitea.io/gitea/modules/setting" @@ -26,21 +26,22 @@ import ( var currentEngine *xorm.Engine -func initMigrationTest() { +func initMigrationTest(t *testing.T) { + integrations.PrintCurrentTest(t, 2) giteaRoot := os.Getenv("GITEA_ROOT") if giteaRoot == "" { - fmt.Println("Environment variable $GITEA_ROOT not set") + integrations.Printf("Environment variable $GITEA_ROOT not set\n") os.Exit(1) } setting.AppPath = path.Join(giteaRoot, "gitea") if _, err := os.Stat(setting.AppPath); err != nil { - fmt.Printf("Could not find gitea binary at %s\n", setting.AppPath) + integrations.Printf("Could not find gitea binary at %s\n", setting.AppPath) os.Exit(1) } giteaConf := os.Getenv("GITEA_CONF") if giteaConf == "" { - fmt.Println("Environment variable $GITEA_CONF not set") + integrations.Printf("Environment variable $GITEA_CONF not set\n") os.Exit(1) } else if !path.IsAbs(giteaConf) { setting.CustomConf = path.Join(giteaRoot, giteaConf) @@ -51,6 +52,7 @@ func initMigrationTest() { setting.NewContext() setting.CheckLFSVersion() models.LoadConfigs() + setting.NewLogServices(true) } func getDialect() string { @@ -125,7 +127,7 @@ func restoreOldDB(t *testing.T, version string) bool { data, err := readSQLFromFile(version) assert.NoError(t, err) if len(data) == 0 { - log.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", models.DbCfg.Type, version) return false } @@ -212,7 +214,8 @@ func wrappedMigrate(x *xorm.Engine) error { } func doMigrationTest(t *testing.T, version string) { - log.Printf("Performing migration test for %s version: %s", models.DbCfg.Type, version) + integrations.PrintCurrentTest(t) + integrations.Printf("Performing migration test for %s version: %s\n", models.DbCfg.Type, version) if !restoreOldDB(t, version) { return } @@ -227,19 +230,22 @@ func doMigrationTest(t *testing.T, version string) { } func TestMigrations(t *testing.T) { - initMigrationTest() + initMigrationTest(t) dialect := models.DbCfg.Type versions, err := availableVersions() assert.NoError(t, err) if len(versions) == 0 { - log.Printf("No old database versions available to migration test for %s\n", dialect) + integrations.Printf("No old database versions available to migration test for %s\n", dialect) return } - log.Printf("Preparing to test %d migrations for %s\n", len(versions), dialect) + integrations.Printf("Preparing to test %d migrations for %s\n", len(versions), dialect) for _, version := range versions { - doMigrationTest(t, version) + t.Run(fmt.Sprintf("Migrate-%s-%s", dialect, version), func(t *testing.T) { + doMigrationTest(t, version) + }) + } } |