Asone / LNFilestoreServer

A pay to download webserver based onto the lightning network
MIT License
7 stars 1 forks source link

Add basic unit tests #1

Open Asone opened 2 years ago

Asone commented 2 years ago

There's currently no unit testing onto the API demo.

At some point, it'd be nice to have those as it would : 1/ Ensure that the demo works as expected 2/ Give example of the different use cases handling to users 3/ Show how to unit test that kind of app

The first step would be to build simple unit test covering : 1/ Juniper 2/ Rocket 3/ Diesel 4/ Lnd Mock

Asone commented 2 years ago

Unit test to do with expected complexity

Asone commented 1 year ago

A few notes regarding unit & integration tests with rustlang and the different aspects of it.

However, the current drafted solution can only create and drop the test database for EACH test. This makes the solution quite slow and painful :

This is an acceptable solution for small test suites, however this definitely can't be considered as a viable solution for long term development.

Unfortunately there is no way to perform operations prior a test suite with cargo for now. A hacky option could be the following one however : https://www.reddit.com/r/rust/comments/9wixkj/how_can_i_run_something_prior_to_all_cargo_tests/

Asone commented 1 year ago

Unfortunately there is no way to perform operations prior a test suite with cargo for now. A hacky option could be the following one however : https://www.reddit.com/r/rust/comments/9wixkj/how_can_i_run_something_prior_to_all_cargo_tests/

It appears that unfortunately the statics don't get a Drop call, which means our temporary test database will never be destroyed.

In order to avoir previous data to remain we could switch to a static name of database and drop previous database on each start of tests