Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting test database in Vapor 3

Tags:

swift

vapor

I want to write some integration tests for Vapor 3 server and I need to have clean Postgre database each time I run my tests. How can I achieve this? It seems migrations isn't the right way to go as they've been running once if database doesn't exist yet.

like image 740
m8labs Avatar asked Nov 19 '18 20:11

m8labs


1 Answers

Have a look at https://github.com/raywenderlich/vapor-til/tree/master/Tests

This requires a DB to be running before you run the tests, but it reverts all migrations at the start of each test run, which gives you a clean DB each time. (Specifically here)

There's also a docker-compose.yml in the root directory for spinning up a completely isolated test environment on Linux

like image 83
0xTim Avatar answered Nov 06 '22 15:11

0xTim