Running gitea tests locally


To run gitea tests locally:


The Gitea test environment docker image conveniently has all the dependencies installed for running tests. It is used by drone but can also be used locally to follow the instructions from the Gitea documentation to run tests without the need to worry about installing dependencies:

docker run --rm -e TAGS=“bindata gogit sqlite sqlite_unlock_notify” -e GOPROXY=off --user gitea -v $(pwd):/drone/src --workdir=/drone/src gitea/test_env:linux-amd64 make unit-test-coverage test-check

Note that it will write files such as coverage.out in the source directory reason why it cannot be mounted as a readonly volume with the :ro suffix.

When make unit-test-coverage is run twice in a row and GITHUB_READ_TOKEN is not set it will exceed the GitHub API rate limit and fail with the following error:

goroutine 54 [select, 10 minutes]:*GithubDownloaderV3).sleep(0xc0000c6620)
	/drone/src/modules/migrations/github.go:121 +0xe5*GithubDownloaderV3).GetReviews(0xc0000c6620, {0x1ef5850, 0x1b90ae8})
	/drone/src/modules/migrations/github.go:754 +0x41c
	/drone/src/modules/migrations/github_test.go:372 +0x2ab8
testing.tRunner(0xc001a824e0, 0x1b90118)
	/usr/local/go/src/testing/testing.go:1259 +0x102
created by testing.(*T).Run
	/usr/local/go/src/testing/testing.go:1306 +0x35a
FAIL	600.448s