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.

57 lines
1.6 KiB

  1. # Integrations tests
  2. Integration tests can be run with make commands for the
  3. appropriate backends, namely:
  4. ```shell
  5. make test-mysql
  6. make test-pgsql
  7. make test-sqlite
  8. ```
  9. Make sure to perform a clean build before running tests:
  10. ```
  11. make clean build
  12. ```
  13. ## Run all tests via local drone
  14. ```
  15. drone exec --local --build-event "pull_request"
  16. ```
  17. ## Run sqlite integrations tests
  18. Start tests
  19. ```
  20. make test-sqlite
  21. ```
  22. ## Run mysql integrations tests
  23. Setup a mysql database inside docker
  24. ```
  25. 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)
  26. ```
  27. Start tests based on the database container
  28. ```
  29. 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
  30. ```
  31. ## Run pgsql integrations tests
  32. Setup a pgsql database inside docker
  33. ```
  34. docker run -e "POSTGRES_DB=test" --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
  35. ```
  36. Start tests based on the database container
  37. ```
  38. 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
  39. ```
  40. ## Running individual tests
  41. Example command to run GPG test with sqlite backend:
  42. ```
  43. go test -c code.gitea.io/gitea/integrations \
  44. -o integrations.sqlite.test -tags 'sqlite' &&
  45. GITEA_ROOT="$GOPATH/src/code.gitea.io/gitea" \
  46. GITEA_CONF=integrations/sqlite.ini ./integrations.sqlite.test \
  47. -test.v -test.run GPG
  48. ```