mirror of https://github.com/statping/statping
Updated Testing (markdown)
parent
1bcf5bd1e2
commit
aadeaf4f43
36
Testing.md
36
Testing.md
|
@ -1,16 +1,34 @@
|
|||
If you want to test your updates with the current golang testing units, you can follow the guide below to run a full test process. Each test for Statping will run in MySQL, Postgres, and SQlite to make sure all database types work correctly.
|
||||
|
||||
## Create Docker Databases
|
||||
The easiest way to run the tests on all 3 databases is by starting temporary databases servers with Docker. Docker is available for Linux, Mac and Windows. You can download/install it by going to the [Docker Installation](https://docs.docker.com/install/) site.
|
||||
## Requirements
|
||||
- Golang (1.14.* or whichever `go.mod` states)
|
||||
- [go.rice](https://github.com/GeertJohan/go.rice) Compiles all assets into golang file
|
||||
- Node (currently using `10.17`)
|
||||
- Yarn
|
||||
- Sass
|
||||
|
||||
```go
|
||||
## Basic Testing
|
||||
The easiest way to run local unit testing by using SQLite and following the commands below...
|
||||
1. Make sure you have the requirements above. (being able to run `rice`)
|
||||
2. `cd frontend && yarn` Install npm packages for the frontend
|
||||
3. `make compile` Creates production version of Vue frontend and compiles all assets with `rice`.
|
||||
4. `make install` Will install `statping` locally so your system test CLI commands/flags.
|
||||
5. `go test -v ./...` Run all tests for Statping.
|
||||
|
||||
## Notifier Testing
|
||||
To test the notifiers, you must include an environment variable that is set in each notifier test. If that notifier test environment variable is not set, it will be skipped.
|
||||
|
||||
## Create Docker Databases
|
||||
For more advanced testing, you can connect to a different type of database by using the `DB_CONN` environment variable. You can start them with Docker. Docker is available for Linux, Mac and Windows. You can download/install it by going to the [Docker Installation](https://docs.docker.com/install/) site.
|
||||
|
||||
```bash
|
||||
docker run -it -d \
|
||||
-p 3306:3306 \
|
||||
-env MYSQL_ROOT_PASSWORD=password123 \
|
||||
-env MYSQL_DATABASE=root mysql
|
||||
```
|
||||
|
||||
```go
|
||||
```bash
|
||||
docker run -it -d \
|
||||
-p 5432:5432 \
|
||||
-env POSTGRES_PASSWORD=password123 \
|
||||
|
@ -18,14 +36,16 @@ docker run -it -d \
|
|||
-env POSTGRES_DB=root postgres
|
||||
```
|
||||
|
||||
Once you have MySQL and Postgres running, you can begin the testing. SQLite database will automatically create a `statup.db` file and will delete after testing.
|
||||
Once you have MySQL and Postgres running, you can begin the testing. SQLite database will automatically create a `statping.db` file and will delete after testing.
|
||||
|
||||
## Run Tests
|
||||
Insert the database environment variables to auto connect the the databases and run the normal test command: `go test -v`. You'll see a verbose output of each test. If all tests pass, make a push request! 💃
|
||||
```go
|
||||
Insert the database environment variables to auto connect the the databases and run the normal test command: `go test -v ./...`. You'll see a verbose output of each test. If all tests pass, make a push request! 💃
|
||||
|
||||
```bash
|
||||
DB_CONN=sqlite \
|
||||
DB_DATABASE=root \
|
||||
DB_USER=root \
|
||||
DB_PASS=password123 \
|
||||
DB_HOST=localhost \
|
||||
go test -v
|
||||
go test -v ./...
|
||||
```
|
Loading…
Reference in New Issue