Skip to content

Commit

Permalink
refactor tests folder + add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tazoeur committed Mar 23, 2020
1 parent 9fe5f9c commit 1a51e7c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
6 changes: 6 additions & 0 deletions tests/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//! # Auth Tests
//!
//! Here should be grouped every test that is related to the
//! user's authentication.
mod register;
23 changes: 5 additions & 18 deletions tests/auth.rs → tests/auth/register.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
//! # Auth Tests
//! # Registration
//!
//! Here should be grouped every test that is related to the
//! user's authentication.
//! Here are grouped the registration tests
//! Those tests attack the `/api/auth/register` route.
/************************* REQUIRE *******************************************/
mod init;

use diesel::query_dsl::RunQueryDsl;

Expand All @@ -15,6 +14,8 @@ use unanimitylibrary::database::models::user::User;
use unanimitylibrary::database::schema::addresses::dsl::addresses;
use unanimitylibrary::database::schema::users::dsl::users;

use super::super::init;

/**************************** TESTS ******************************************/

#[test]
Expand Down Expand Up @@ -105,17 +106,3 @@ fn register_full_address() {
// check that this address is the one we just added
assert_eq!(tab_address[0].street, "rue grandganage");
}

// test register avec addresse ok
// test register addresse pas ok
// test register existing email
// test double register same address

// test activation good code good id
// test activation wrong code good id
// test activation good code wrong id
// test activation wrong code wrong id
// test double activation

// test login inactive account
// test login active account
15 changes: 15 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! # Tests
//!
//! The tests are organized by folder.
//!
//! To run the tests, please limit the number of threads with
//! `cargo test -- --test-threads=1`.
//! Since the database is reset at the begining of each test, this is the best
//! way to prevent the use of shared state.
//!
//! Cargo by default only tests the files that are at the root of the `/tests`
//! directory.
//! So we have to add all the modules that are used for testing purposes.
mod auth;
mod init;

0 comments on commit 1a51e7c

Please sign in to comment.