Table of Contents
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.
Requirements
- Golang (1.14.* or whichever
go.mod
states)- go.rice Compiles all assets into golang file
- Node (currently using
10.17
)- Yarn
- Sass
Basic Testing
The easiest way to run local unit testing by using SQLite and following the commands below...
- Make sure you have the requirements above. (being able to run
rice
) cd frontend && yarn
Install npm packages for the frontendmake compile
Creates production version of Vue frontend and compiles all assets withrice
.make install
Will installstatping
locally so your system test CLI commands/flags.go test -v ./...
Run all tests for Statping.
If you run Statping on port 8585, and then run
yarn dev
the debug Vue server will be running on port 8888.
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 site.
docker run -it -d \
-p 3306:3306 \
-env MYSQL_ROOT_PASSWORD=password123 \
-env MYSQL_DATABASE=root mysql
docker run -it -d \
-p 5432:5432 \
-env POSTGRES_PASSWORD=password123 \
-env POSTGRES_USER=root \
-env POSTGRES_DB=root postgres
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! 💃
DB_CONN=sqlite \
DB_DATABASE=root \
DB_USER=root \
DB_PASS=password123 \
DB_HOST=localhost \
go test -v ./...
Overview
Installation
Extras
Contact
Email: info@statping.com
Badges
Statping.com | Demo | Docker | Notifiers | API