Testrig fixes (#50)

* testrig is runnable again
* little fixes, add some more test models
* address https://github.com/superseriousbusiness/gotosocial/issues/44
This commit is contained in:
Tobi Smethurst 2021-06-21 12:27:23 +02:00 committed by GitHub
commit efbd839181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 379 additions and 209 deletions

View file

@ -56,6 +56,42 @@ docker run -d --user postgres --network host sosedoff/pgweb
This will launch a pgweb at `http://localhost:8081`.
### Standalone Testrig
You can also launch a testrig as a standalone server running at localhost, which you can connect to using something like [Pinafore](https://github.com/nolanlawson/pinafore).
To do this, first build the gotosocial binary with `go build ./cmd/gotosocial`.
Then launch a clean Postgres container on localhost:
```bash
docker run -d --user postgres --network host -e POSTGRES_PASSWORD=postgres postgres
```
Then, launch the testrig by invoking the binary as follows:
```bash
./gotosocial --host localhost:8080 testrig start
```
To run Pinafore locally in dev mode, first clone the Pinafore repository, and run the following command in the cloned directory:
```bash
yarn run dev
```
The Pinafore instance will start running on `localhost:4002`.
To connect to the testrig, navigate to `https://localhost:4002` and enter your instance name as `localhost:8080`.
At the login screen, enter the email address `zork@example.org` and password `password`.
Note the following constraints:
- The testrig data will be destroyed when the testrig is destroyed. It does this by dropping all tables in Postgres on shutdown. As such, you should **NEVER RUN THE TESTRIG AGAINST A DATABASE WITH REAL DATA IN IT** because it will be destroyed. Be especially careful if you're forwarding database ports from a remote instance to your local machine, because you can easily and irreversibly nuke that data if you run the testrig against it.
- If you stop the testrig and start it again, any tokens or applications you created during your tests will also be removed. As such, you need to log out and in again every time you stop/start the rig.
- The testrig does not make any actual external http calls, so federation will (obviously) not work from a testrig.
## Running tests
Because the tests use a real Postgres under the hood, you can't run them in parallel, so you need to run tests with the following command:
@ -98,4 +134,4 @@ Then make sure to run `go fmt ./...` to update whitespace and other opinionated
Right now there's no structure in place for financial compensation for pull requests and code. This is simply because there's no money being made on the project apart from the very small weekly Liberapay donations.
If money starts coming in, I'll start looking at proper financial structures, but for now code is considered to be a donation in itself.
If money starts coming in, I'll start looking at proper financial structures, but for now code is considered to be a donation in itself.