diff options
author | James Fargher <proglottis@gmail.com> | 2023-04-12 03:06:11 +0300 |
---|---|---|
committer | James Fargher <proglottis@gmail.com> | 2023-04-12 03:06:11 +0300 |
commit | a5d056f2e268a775f6742046e284f33bae43078b (patch) | |
tree | ddd30fc0888c726674c1db944b75cccba5b5cd12 | |
parent | 4ad3613cdc0c0ec0970578a6fdb3c17f06ceba6e (diff) | |
parent | 3252ddd0b4588f43c5c0551ff648c41a64b90236 (diff) |
Merge branch 'toon-no-moar-rspec-docs' into 'master'
docs: Remove rspec from the beginner's guide
See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5617
Merged-by: James Fargher <proglottis@gmail.com>
Approved-by: Evan Read <eread@gitlab.com>
Approved-by: James Fargher <proglottis@gmail.com>
Reviewed-by: Evan Read <eread@gitlab.com>
Co-authored-by: Evan Read <eread@gitlab.com>
Co-authored-by: Toon Claes <toon@gitlab.com>
-rw-r--r-- | doc/beginners_guide.md | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/doc/beginners_guide.md b/doc/beginners_guide.md index 3e7ec50d5..b9dc8df02 100644 --- a/doc/beginners_guide.md +++ b/doc/beginners_guide.md @@ -133,32 +133,15 @@ If proto is updated, run `make`. This should compile successfully. ## Testing -Gitaly's tests are mostly written in Go but it is possible to write RSpec tests too. +Gitaly's tests are mostly in Go and we apply the following guidelines: -Generally, you should always write new tests in Go even when testing Ruby code, -since we're planning to gradually rewrite everything in Go and want to avoid -having to rewrite the tests as well. - -Because Praefect lives in the same repository we need to provide database connection -information in order to run tests for it successfully. To get more info check out -[glsql](../internal/praefect/datastore/glsql/doc.go) package documentation. - -The easiest way to set up a Postgres database instance is to run it as a Docker container: - -```bash -docker rm -f $(docker ps -q --all -f name=praefect-pg) > /dev/null 2>1; \ -docker run --name praefect-pg -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:12.6 -``` +- Each RPC must have end-to-end tests at the service level. +- (Optional) Add unit tests for functions that need more coverage. To run the full test suite, use `make test`. You'll need some [test repositories](test_repos.md), you can set these up with `make prepare-tests`. -### Go tests - -- each RPC must have end-to-end tests at the service level -- optionally, you can add unit tests for functions that need more coverage - -#### Integration Tests +### Integration Tests A typical set of Go tests for an RPC consists of two or three test functions: @@ -171,7 +154,7 @@ Our Go RPC tests use in-process test servers that only implement the service the For example, if you are working on an RPC in the 'RepositoryService', your tests would go in `internal/gitaly/service/repository/your_rpc_test.go`. -#### Running a specific test +### Running a specific test When you are trying to fix a specific test failure it is inefficient to run `make test` all the time. To run just one test you need to know @@ -193,7 +176,7 @@ called on `testing.T`. [require]: https://github.com/stretchr/testify/tree/master/require [assert]: https://github.com/stretchr/testify/tree/master/assert -#### Using Delve to debug a test +### Using Delve to debug a test The process to debug a test in your terminal using [Delve](https://github.com/go-delve/delve) is almost the same as @@ -204,9 +187,29 @@ target to `debug-test-go`: TEST_PACKAGES=./internal/gitaly/service/repository TEST_OPTIONS="-count=1 -run=TestRepositoryExists" make debug-test-go ``` -#### Useful snippets for creating a test +### Praefect tests + +Because Praefect lives in the same repository, we need to provide database connection +information to run tests for it successfully. For more information, see +[glsql](../internal/praefect/datastore/glsql/doc.go) package documentation. + +When using [GDK](https://gitlab.com/gitlab-org/gitlab-development-kit/), +the easiest way to run a PostgreSQL database is by running: + +```shell +gdk start db +``` + +Otherwise, you can set up a PostgreSQL database instance as a Docker container: + +```shell +docker rm -f $(docker ps -q --all -f name=praefect-pg) > /dev/null 2>1; \ +docker run --name praefect-pg -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:12.6 +``` + +### Useful snippets for creating a test -##### testhelper package +#### testhelper package The `testhelper` package provides functions to create configurations to run Gitaly and helpers to run a Gitaly gRPC server: |