Trioxidation / Triox

A free file hosting server that focuses on speed, reliability and security.
GNU Affero General Public License v3.0
102 stars 14 forks source link

Tests for files app #5

Closed AaronErhardt closed 2 years ago

AaronErhardt commented 4 years ago

Tests for the file API (more in API.md) would be great to make sure that the file app does it's job correctly. It should be possible to write most tests for this using Actix web's integrated testing tools, similar to src/tests/auth_test.rs.

Possibly, some tests might require more flexibility than Actix can cover. In this case I suggest using Reqwest. Note that before testing with Reqwest you need to start the triox server.

Every service should be checked whether it works as expected and how it handles bad or malicious input.

List of services that need tests:

boleaczek commented 3 years ago

Hi, I wanted to write some tests for get, but several test methods from sign_up module fail with:

error[E0277]: a value of type `std::string::String` cannot be built from an iterator over elements of type `u8`
   --> src/tests/auth_test.rs:107:62
    |
107 |             thread_rng().sample_iter(&Alphanumeric).take(10).collect();
    |                                                              ^^^^^^^ value of type `std::string::String` cannot be built from `std::iter::Iterator<Item=u8>`
    |
    = help: the trait `FromIterator<u8>` is not implemented for `std::string::String`

I can work around it just fine if I comment them or fix them locally, but I'm curious if maybe I'm missing something here.

AaronErhardt commented 3 years ago

@boleaczek thanks a lot for considering contributing!

The errors are actually my bad, I recently improved the error messages but forgot to update the error messages expected in the tests. Sorry for the inconvenience, I just pushed a fix to the master branch.