File tree Expand file tree Collapse file tree 2 files changed +64
-7
lines changed Expand file tree Collapse file tree 2 files changed +64
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
Integration tests can be run with make commands for the
4
4
appropriate backends, namely:
5
-
6
- make test-mysql
7
- make test-pgsql
8
- make test-sqlite
5
+ ``` shell
6
+ make test-mysql
7
+ make test-pgsql
8
+ make test-sqlite
9
+ ```
9
10
10
11
Make sure to perform a clean build before running tests:
11
-
12
- make clean build
12
+ ```
13
+ make clean build
14
+ ```
13
15
14
16
## Run all tests via local drone
15
17
```
@@ -45,7 +47,6 @@ TEST_PGSQL_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAdd
45
47
## Running individual tests
46
48
47
49
Example command to run GPG test with sqlite backend:
48
-
49
50
```
50
51
go test -c code.gitea.io/gitea/integrations \
51
52
-o integrations.sqlite.test -tags 'sqlite' &&
Original file line number Diff line number Diff line change
1
+ # 关于集成测试
2
+
3
+ 使用如下 make 命令可以运行指定的集成测试:
4
+ ``` shell
5
+ make test-mysql
6
+ make test-pgsql
7
+ make test-sqlite
8
+ ```
9
+
10
+ 在执行集成测试命令前请确保清理了之前的构建环境,清理命令如下:
11
+ ```
12
+ make clean build
13
+ ```
14
+
15
+ ## 如何在本地 drone 服务器上运行所有测试
16
+ ```
17
+ drone exec --local --build-event "pull_request"
18
+ ```
19
+
20
+ ## 如何使用 sqlite 数据库进行集成测试
21
+ 使用该命令执行集成测试
22
+ ```
23
+ make test-sqlite
24
+ ```
25
+
26
+ ## 如何使用 mysql 数据库进行集成测试
27
+ 首先在docker容器里部署一个 mysql 数据库
28
+ ```
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)
30
+ ```
31
+ 之后便可以基于这个数据库进行集成测试
32
+ ```
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
34
+ ```
35
+
36
+ ## 如何使用 pgsql 数据库进行集成测试
37
+ 同上,首先在 docker 容器里部署一个 pgsql 数据库
38
+ ```
39
+ docker run -e "POSTGRES_DB=test" --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
40
+ ```
41
+ 之后便可以基于这个数据库进行集成测试
42
+ ```
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
44
+ ```
45
+
46
+ ## 如何进行自定义的集成测试
47
+
48
+ 下面的示例展示了怎样基于 sqlite 数据库进行 GPG 测试:
49
+ ```
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
55
+ ```
56
+
You can’t perform that action at this time.
0 commit comments