Skip to content

Commit 51a8713

Browse files
Merge branch 'master' into team-permission-create-repo
2 parents f59f511 + 5774260 commit 51a8713

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1511
-315
lines changed

Makefile

Lines changed: 87 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -204,94 +204,140 @@ test-sqlite\#%: integrations.sqlite.test
204204
test-sqlite-migration: migrations.sqlite.test
205205
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./migrations.sqlite.test
206206

207-
generate-ini:
207+
generate-ini-mysql:
208208
sed -e 's|{{TEST_MYSQL_HOST}}|${TEST_MYSQL_HOST}|g' \
209209
-e 's|{{TEST_MYSQL_DBNAME}}|${TEST_MYSQL_DBNAME}|g' \
210210
-e 's|{{TEST_MYSQL_USERNAME}}|${TEST_MYSQL_USERNAME}|g' \
211211
-e 's|{{TEST_MYSQL_PASSWORD}}|${TEST_MYSQL_PASSWORD}|g' \
212212
integrations/mysql.ini.tmpl > integrations/mysql.ini
213+
214+
.PHONY: test-mysql
215+
test-mysql: integrations.mysql.test generate-ini-mysql
216+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test
217+
218+
.PHONY: test-mysql\#%
219+
test-mysql\#%: integrations.mysql.test generate-ini-mysql
220+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.run $*
221+
222+
.PHONY: test-mysql-migration
223+
test-mysql-migration: migrations.mysql.test generate-ini-mysql
224+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./migrations.mysql.test
225+
226+
227+
generate-ini-mysql8:
213228
sed -e 's|{{TEST_MYSQL8_HOST}}|${TEST_MYSQL8_HOST}|g' \
214229
-e 's|{{TEST_MYSQL8_DBNAME}}|${TEST_MYSQL8_DBNAME}|g' \
215230
-e 's|{{TEST_MYSQL8_USERNAME}}|${TEST_MYSQL8_USERNAME}|g' \
216231
-e 's|{{TEST_MYSQL8_PASSWORD}}|${TEST_MYSQL8_PASSWORD}|g' \
217232
integrations/mysql8.ini.tmpl > integrations/mysql8.ini
233+
234+
.PHONY: test-mysql8
235+
test-mysql8: integrations.mysql8.test generate-ini-mysql8
236+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test
237+
238+
.PHONY: test-mysql8\#%
239+
test-mysql8\#%: integrations.mysql8.test generate-ini-mysql8
240+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.mysql8.test -test.run $*
241+
242+
.PHONY: test-mysql8-migration
243+
test-mysql8-migration: migrations.mysql8.test generate-ini-mysql8
244+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./migrations.mysql8.test
245+
246+
247+
generate-ini-pgsql:
218248
sed -e 's|{{TEST_PGSQL_HOST}}|${TEST_PGSQL_HOST}|g' \
219249
-e 's|{{TEST_PGSQL_DBNAME}}|${TEST_PGSQL_DBNAME}|g' \
220250
-e 's|{{TEST_PGSQL_USERNAME}}|${TEST_PGSQL_USERNAME}|g' \
221251
-e 's|{{TEST_PGSQL_PASSWORD}}|${TEST_PGSQL_PASSWORD}|g' \
222252
integrations/pgsql.ini.tmpl > integrations/pgsql.ini
223-
sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
224-
-e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
225-
-e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
226-
-e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
227-
integrations/mssql.ini.tmpl > integrations/mssql.ini
228-
229-
.PHONY: test-mysql
230-
test-mysql: integrations.test generate-ini
231-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test
232253

233-
.PHONY: test-mysql-migration
234-
test-mysql-migration: migrations.test generate-ini
235-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./migrations.test
254+
.PHONY: test-pgsql
255+
test-pgsql: integrations.pgsql.test generate-ini-pgsql
256+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test
236257

237-
.PHONY: test-mysql8
238-
test-mysql8: integrations.test generate-ini
239-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./integrations.test
258+
.PHONY: test-pgsql\#%
259+
test-pgsql\#%: integrations.pgsql.test generate-ini-pgsql
260+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.run $*
240261

241-
.PHONY: test-mysql8-migration
242-
test-mysql8-migration: migrations.test generate-ini
243-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql8.ini ./migrations.test
262+
.PHONY: test-pgsql-migration
263+
test-pgsql-migration: migrations.pgsql.test generate-ini-pgsql
264+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./migrations.pgsql.test
244265

245-
.PHONY: test-pgsql
246-
test-pgsql: integrations.test generate-ini
247-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test
248266

249-
.PHONY: test-pgsql-migration
250-
test-pgsql-migration: migrations.test generate-ini
251-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./migrations.test
267+
generate-ini-mssql:
268+
sed -e 's|{{TEST_MSSQL_HOST}}|${TEST_MSSQL_HOST}|g' \
269+
-e 's|{{TEST_MSSQL_DBNAME}}|${TEST_MSSQL_DBNAME}|g' \
270+
-e 's|{{TEST_MSSQL_USERNAME}}|${TEST_MSSQL_USERNAME}|g' \
271+
-e 's|{{TEST_MSSQL_PASSWORD}}|${TEST_MSSQL_PASSWORD}|g' \
272+
integrations/mssql.ini.tmpl > integrations/mssql.ini
252273

253274
.PHONY: test-mssql
254-
test-mssql: integrations.test generate-ini
255-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.test
275+
test-mssql: integrations.mssql.test generate-ini-mssql
276+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test
277+
278+
.PHONY: test-mssql\#%
279+
test-mssql\#%: integrations.mssql.test generate-ini-mssql
280+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.run $*
256281

257282
.PHONY: test-mssql-migration
258-
test-mssql-migration: migrations.test generate-ini
259-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./migrations.test
283+
test-mssql-migration: migrations.mssql.test generate-ini-mssql
284+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./migrations.mssql.test
260285

261286

262287
.PHONY: bench-sqlite
263288
bench-sqlite: integrations.sqlite.test
264289
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
265290

266291
.PHONY: bench-mysql
267-
bench-mysql: integrations.test generate-ini
268-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
292+
bench-mysql: integrations.mysql.test generate-ini-mysql
293+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.mysql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
269294

270295
.PHONY: bench-mssql
271-
bench-mssql: integrations.test generate-ini
272-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
296+
bench-mssql: integrations.mssql.test generate-ini-mssql
297+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mssql.ini ./integrations.mssql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
273298

274299
.PHONY: bench-pgsql
275-
bench-pgsql: integrations.test generate-ini
276-
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
300+
bench-pgsql: integrations.pgsql.test generate-ini-pgsql
301+
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/pgsql.ini ./integrations.pgsql.test -test.cpuprofile=cpu.out -test.run DontRunTests -test.bench .
277302

278303

279304
.PHONY: integration-test-coverage
280-
integration-test-coverage: integrations.cover.test generate-ini
305+
integration-test-coverage: integrations.cover.test generate-ini-mysql
281306
GITEA_ROOT=${CURDIR} GITEA_CONF=integrations/mysql.ini ./integrations.cover.test -test.coverprofile=integration.coverage.out
282307

283-
integrations.test: $(SOURCES)
284-
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.test
308+
integrations.mysql.test: $(SOURCES)
309+
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql.test
310+
311+
integrations.mysql8.test: $(SOURCES)
312+
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mysql8.test
313+
314+
integrations.pgsql.test: $(SOURCES)
315+
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.pgsql.test
316+
317+
integrations.mssql.test: $(SOURCES)
318+
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.mssql.test
285319

286320
integrations.sqlite.test: $(SOURCES)
287321
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -o integrations.sqlite.test -tags 'sqlite sqlite_unlock_notify'
288322

289323
integrations.cover.test: $(SOURCES)
290324
GO111MODULE=on $(GO) test -mod=vendor -c code.gitea.io/gitea/integrations -coverpkg $(shell echo $(PACKAGES) | tr ' ' ',') -o integrations.cover.test
291325

292-
.PHONY: migrations.test
293-
migrations.test: $(SOURCES)
294-
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.test
326+
.PHONY: migrations.mysql.test
327+
migrations.mysql.test: $(SOURCES)
328+
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql.test
329+
330+
.PHONY: migrations.mysql8.test
331+
migrations.mysql8.test: $(SOURCES)
332+
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mysql8.test
333+
334+
.PHONY: migrations.pgsql.test
335+
migrations.pgsql.test: $(SOURCES)
336+
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.pgsql.test
337+
338+
.PHONY: migrations.mssql.test
339+
migrations.mssql.test: $(SOURCES)
340+
$(GO) test -c code.gitea.io/gitea/integrations/migration-test -o migrations.mssql.test
295341

296342
.PHONY: migrations.sqlite.test
297343
migrations.sqlite.test: $(SOURCES)

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ In order to get file rendering through external binaries, their associated packa
2828
If you're using a Docker image, your `Dockerfile` should contain something along this lines:
2929

3030
```
31-
FROM gitea/gitea:1.6.0
31+
FROM gitea/gitea:{{< version >}}
3232
[...]
3333
3434
COPY custom/app.ini /data/gitea/conf/app.ini
3535
[...]
3636
37-
RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng python-dev py-pip python3-dev py3-pip
37+
RUN apk --no-cache add asciidoctor freetype freetype-dev gcc g++ libpng python-dev py-pip python3-dev py3-pip py3-zmq
3838
# install any other package you need for your external renderers
3939
4040
RUN pip3 install --upgrade pip

docs/content/doc/advanced/hacking-on-gitea.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ make generate-swagger
178178
You should validate your generated Swagger file and spell-check it with:
179179

180180
```bash
181-
make swagger-validate mispell-check
181+
make swagger-validate misspell-check
182182
```
183183

184184
You should commit the changed swagger JSON file. The continous integration

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ require (
4848
github.com/go-redis/redis v6.15.2+incompatible
4949
github.com/go-sql-driver/mysql v1.4.1
5050
github.com/go-swagger/go-swagger v0.20.1
51-
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67
51+
github.com/go-xorm/xorm v0.7.8
5252
github.com/gobwas/glob v0.2.3
5353
github.com/gogits/chardet v0.0.0-20150115103509-2404f7772561
5454
github.com/gogs/cron v0.0.0-20171120032916-9f6c956d3e14
@@ -125,5 +125,5 @@ require (
125125
mvdan.cc/xurls/v2 v2.0.0
126126
strk.kbt.io/projects/go/libravatar v0.0.0-20160628055650-5eed7bff870a
127127
xorm.io/builder v0.3.6
128-
xorm.io/core v0.7.0
128+
xorm.io/core v0.7.2
129129
)

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@ github.com/go-swagger/scan-repo-boundary v0.0.0-20180623220736-973b3573c013/go.m
250250
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:9wScpmSP5A3Bk8V3XHWUcJmYTh+ZnlHVyc+A4oZYS3Y=
251251
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM=
252252
github.com/go-xorm/xorm v0.7.6/go.mod h1:nqz2TAsuOHWH2yk4FYWtacCGgdbrcdZ5mF1XadqEHls=
253-
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67 h1:mB5RWONyATkQ48+iQZ1lCZNPG3tABilyaEOxDm1QWyU=
254-
github.com/go-xorm/xorm v0.7.8-0.20190924080535-59ed80ce1a67/go.mod h1:RSsmsVARCy4sayuKWFPaVNQMPYGLNRIK71YIVvgImL0=
253+
github.com/go-xorm/xorm v0.7.8 h1:rKxZJB9mWQ9Nw2TbjsepiThR031jkGePOWXwTtEAU08=
254+
github.com/go-xorm/xorm v0.7.8/go.mod h1:XiVxrMMIhFkwSkh96BW7PACl7UhLtx2iJIHMdmjh5sQ=
255255
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
256256
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
257257
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
@@ -824,3 +824,7 @@ xorm.io/builder v0.3.6 h1:ha28mQ2M+TFx96Hxo+iq6tQgnkC9IZkM6D8w9sKHHF8=
824824
xorm.io/builder v0.3.6/go.mod h1:LEFAPISnRzG+zxaxj2vPicRwz67BdhFreKg8yv8/TgU=
825825
xorm.io/core v0.7.0 h1:hKxuOKWZNeiFQsSuGet/KV8HZ788hclvAl+7azx3tkM=
826826
xorm.io/core v0.7.0/go.mod h1:TuOJjIVa7e3w/rN8tDcAvuLBMtwzdHPbyOzE6Gk1EUI=
827+
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb h1:msX3zG3BPl8Ti+LDzP33/9K7BzO/WqFXk610K1kYKfo=
828+
xorm.io/core v0.7.2-0.20190928055935-90aeac8d08eb/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=
829+
xorm.io/core v0.7.2 h1:mEO22A2Z7a3fPaZMk6gKL/jMD80iiyNwRrX5HOv3XLw=
830+
xorm.io/core v0.7.2/go.mod h1:jJfd0UAEzZ4t87nbQYtVjmqpIODugN6PD2D9E+dJvdM=

integrations/README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,45 @@ make test-sqlite
2727
## Run mysql integrations tests
2828
Setup a mysql database inside docker
2929
```
30-
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
30+
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
3131
```
3232
Start tests based on the database container
3333
```
34-
TEST_MYSQL_HOST="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql):3306" TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql
34+
TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql
3535
```
3636

3737
## Run pgsql integrations tests
3838
Setup a pgsql database inside docker
3939
```
40-
docker run -e "POSTGRES_DB=test" --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
40+
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
4141
```
4242
Start tests based on the database container
4343
```
44-
TEST_PGSQL_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql) TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
44+
TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
45+
```
46+
47+
## Run mssql integrations tests
48+
Setup a mssql database inside docker
49+
```
50+
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container)
51+
```
52+
Start tests based on the database container
53+
```
54+
TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql
4555
```
4656

4757
## Running individual tests
4858

49-
Example command to run GPG test with sqlite backend:
59+
Example command to run GPG test:
60+
61+
For sqlite:
62+
5063
```
51-
go test -c code.gitea.io/gitea/integrations \
52-
-o integrations.sqlite.test -tags 'sqlite' &&
53-
GITEA_ROOT="$GOPATH/src/code.gitea.io/gitea" \
54-
GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test \
55-
-test.v -test.run GPG
64+
make test-sqlite#GPG
5665
```
5766

67+
For other databases(replace MSSQL to MYSQL, MYSQL8, PGSQL):
68+
69+
```
70+
TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG
71+
```

integrations/README_ZH.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,46 @@ make test-sqlite
2626
## 如何使用 mysql 数据库进行集成测试
2727
首先在docker容器里部署一个 mysql 数据库
2828
```
29-
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
29+
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
3030
```
3131
之后便可以基于这个数据库进行集成测试
3232
```
33-
TEST_MYSQL_HOST="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql):3306" TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql
33+
TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root TEST_MYSQL_PASSWORD='' make test-mysql
3434
```
3535

3636
## 如何使用 pgsql 数据库进行集成测试
3737
同上,首先在 docker 容器里部署一个 pgsql 数据库
3838
```
39-
docker run -e "POSTGRES_DB=test" --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
39+
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
4040
```
4141
之后便可以基于这个数据库进行集成测试
4242
```
43-
TEST_PGSQL_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql) TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
43+
TEST_PGSQL_HOST=localhost:5432 TEST_PGSQL_DBNAME=test TEST_PGSQL_USERNAME=postgres TEST_PGSQL_PASSWORD=postgres make test-pgsql
44+
```
45+
46+
## Run mssql integrations tests
47+
同上,首先在 docker 容器里部署一个 mssql 数据库
48+
```
49+
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_PID=Standard" -e "SA_PASSWORD=MwantsaSecurePassword1" -p 1433:1433 --rm --name mssql microsoft/mssql-server-linux:latest #(just ctrl-c to stop db and clean the container)
50+
```
51+
之后便可以基于这个数据库进行集成测试
52+
```
53+
TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=gitea_test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql
4454
```
4555

4656
## 如何进行自定义的集成测试
4757

48-
下面的示例展示了怎样基于 sqlite 数据库进行 GPG 测试:
58+
下面的示例展示了怎样在集成测试中只进行 GPG 测试:
59+
60+
sqlite 数据库:
61+
62+
```
63+
make test-sqlite#GPG
64+
```
65+
66+
其它数据库(把 MSSQL 替换为 MYSQL, MYSQL8, PGSQL):
67+
4968
```
50-
go test -c code.gitea.io/gitea/integrations \
51-
-o integrations.sqlite.test -tags 'sqlite' &&
52-
GITEA_ROOT="$GOPATH/src/code.gitea.io/gitea" \
53-
GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test \
54-
-test.v -test.run GPG
69+
TEST_MSSQL_HOST=localhost:1433 TEST_MSSQL_DBNAME=test TEST_MSSQL_USERNAME=sa TEST_MSSQL_PASSWORD=MwantsaSecurePassword1 make test-mssql#GPG
5570
```
5671

integrations/integration_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func initIntegrationTest() {
131131
if err != nil {
132132
log.Fatalf("sql.Open: %v", err)
133133
}
134-
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS testgitea"); err != nil {
134+
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", setting.Database.Name)); err != nil {
135135
log.Fatalf("db.Exec: %v", err)
136136
}
137137
case setting.Database.UsePostgreSQL:
@@ -150,7 +150,7 @@ func initIntegrationTest() {
150150
if rows.Next() {
151151
break
152152
}
153-
if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil {
153+
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE %s", setting.Database.Name)); err != nil {
154154
log.Fatalf("db.Exec: %v", err)
155155
}
156156
case setting.Database.UseMSSQL:
@@ -160,7 +160,7 @@ func initIntegrationTest() {
160160
if err != nil {
161161
log.Fatalf("sql.Open: %v", err)
162162
}
163-
if _, err := db.Exec("If(db_id(N'gitea') IS NULL) BEGIN CREATE DATABASE gitea; END;"); err != nil {
163+
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 {
164164
log.Fatalf("db.Exec: %v", err)
165165
}
166166
defer db.Close()

integrations/mssql.ini.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PROVIDER_CONFIG = data/sessions-mssql
6262

6363
[log]
6464
MODE = test,file
65-
ROOT_PATH = sqlite-log
65+
ROOT_PATH = mssql-log
6666
REDIRECT_MACARON_LOG = true
6767
ROUTER = ,
6868
MACARON = ,

0 commit comments

Comments
 (0)