You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README_ZH.md 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # 关于集成测试
  2. 使用如下 make 命令可以运行指定的集成测试:
  3. ```shell
  4. make test-mysql
  5. make test-pgsql
  6. make test-sqlite
  7. ```
  8. 在执行集成测试命令前请确保清理了之前的构建环境,清理命令如下:
  9. ```
  10. make clean build
  11. ```
  12. ## 如何在本地 drone 服务器上运行所有测试
  13. ```
  14. drone exec --local --build-event "pull_request"
  15. ```
  16. ## 如何使用 sqlite 数据库进行集成测试
  17. 使用该命令执行集成测试
  18. ```
  19. make test-sqlite
  20. ```
  21. ## 如何使用 mysql 数据库进行集成测试
  22. 首先在docker容器里部署一个 mysql 数据库
  23. ```
  24. 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)
  25. ```
  26. 之后便可以基于这个数据库进行集成测试
  27. ```
  28. 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
  29. ```
  30. ## 如何使用 pgsql 数据库进行集成测试
  31. 同上,首先在 docker 容器里部署一个 pgsql 数据库
  32. ```
  33. docker run -e "POSTGRES_DB=test" --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
  34. ```
  35. 之后便可以基于这个数据库进行集成测试
  36. ```
  37. 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
  38. ```
  39. ## 如何进行自定义的集成测试
  40. 下面的示例展示了怎样基于 sqlite 数据库进行 GPG 测试:
  41. ```
  42. go test -c code.gitea.io/gitea/integrations \
  43. -o integrations.sqlite.test -tags 'sqlite' &&
  44. GITEA_ROOT="$GOPATH/src/code.gitea.io/gitea" \
  45. GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test \
  46. -test.v -test.run GPG
  47. ```