Skip to content

Commit d98a86d

Browse files
lunnybkcsoft
authored andcommitted
remove sqlite tag when integration test with mysql/postgres AND recreate database when init integration test (#1693)
1 parent 377acb9 commit d98a86d

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ test-vendor:
9696
govendor status || exit 1
9797

9898
.PHONY: test-sqlite
99-
test-sqlite: integrations.test
99+
test-sqlite:
100+
go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
100101
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.test
101102

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

110111
integrations.test: $(SOURCES)
111-
go test -c code.gitea.io/gitea/integrations -tags 'sqlite'
112+
go test -c code.gitea.io/gitea/integrations
112113

113114
.PHONY: check
114115
check: test

integrations/integration_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ func initIntegrationTest() {
7979
if err != nil {
8080
log.Fatalf("sql.Open: %v", err)
8181
}
82+
if _, err = db.Exec("DROP DATABASE IF EXISTS testgitea"); err != nil {
83+
log.Fatalf("db.drop db: %v", err)
84+
}
8285
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil {
8386
log.Fatalf("db.Exec: %v", err)
8487
}
@@ -96,11 +99,14 @@ func initIntegrationTest() {
9699
}
97100
defer rows.Close()
98101

99-
if !rows.Next() {
100-
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
101-
log.Fatalf("db.Exec: %v", err)
102+
if rows.Next() {
103+
if _, err = db.Exec("DROP DATABASE testgitea"); err != nil {
104+
log.Fatalf("db.drop db: %v", err)
102105
}
103106
}
107+
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
108+
log.Fatalf("db.Exec: %v", err)
109+
}
104110
}
105111
routers.GlobalInit()
106112
}

0 commit comments

Comments
 (0)