Browse Source

remove sqlite tag when integration test with mysql/postgres AND recreate database when init integration test (#1693)

master
Lunny Xiao Kim "BKC" Carlbäcker 8 years ago
parent
commit
d98a86d2a2
2 changed files with 12 additions and 5 deletions
  1. +3
    -2
      Makefile
  2. +9
    -3
      integrations/integration_test.go

+ 3
- 2
Makefile View File

@@ -96,7 +96,8 @@ test-vendor:
govendor status || exit 1 govendor status || exit 1


.PHONY: test-sqlite .PHONY: test-sqlite
test-sqlite: integrations.test
test-sqlite:
go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.test


.PHONY: test-mysql .PHONY: test-mysql
@@ -108,7 +109,7 @@ test-pgsql: integrations.test
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test


integrations.test: $(SOURCES) integrations.test: $(SOURCES)
go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
go test -c code.gitea.io/gitea/integrations


.PHONY: check .PHONY: check
check: test check: test


+ 9
- 3
integrations/integration_test.go View File

@@ -79,6 +79,9 @@ func initIntegrationTest() {
if err != nil { if err != nil {
log.Fatalf("sql.Open: %v", err) log.Fatalf("sql.Open: %v", err)
} }
if _, err = db.Exec("DROP DATABASE IF EXISTS testgitea"); err != nil {
log.Fatalf("db.drop db: %v", err)
}
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil { if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err) log.Fatalf("db.Exec: %v", err)
} }
@@ -96,11 +99,14 @@ func initIntegrationTest() {
} }
defer rows.Close() defer rows.Close()


if !rows.Next() {
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
if rows.Next() {
if _, err = db.Exec("DROP DATABASE testgitea"); err != nil {
log.Fatalf("db.drop db: %v", err)
} }
} }
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
log.Fatalf("db.Exec: %v", err)
}
} }
routers.GlobalInit() routers.GlobalInit()
} }


Loading…
Cancel
Save