-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #128: Refactor: extract logic from E2E tests to reuse it for in…
…tegration tests 489061e refactor: extract logic from e2e tests to reuse it for integrations tests (Jose Celano) Pull request description: E2E tests run an independent application process with docker, and then the test are executed against that single service. Integration tests will use an independent process for each test, running the API on a different port. The tests launch their instances. We need to refactor the application bootstrapping to be able to launch an app instance programmatically, as we did for the tracker. This refactoring allows us to reuse the code from E2E tests in future integration tests. Top commit has no ACKs. Tree-SHA512: 08a6238007bc3abb090d688fda6f582c94de4587af59ba3ec131447833081de4c1ff885a68a821254e59d80dcc9a7526c00e3b2f0c7f108fb22e28d4335a76d8
- Loading branch information
Showing
48 changed files
with
436 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use rand::Rng; | ||
|
||
pub fn software_predefined_category_name() -> String { | ||
"software".to_string() | ||
} | ||
|
||
pub fn software_predefined_category_id() -> i64 { | ||
5 | ||
} | ||
|
||
pub fn random_category_name() -> String { | ||
format!("category name {}", random_id()) | ||
} | ||
|
||
fn random_id() -> u64 { | ||
let mut rng = rand::thread_rng(); | ||
rng.gen_range(0..1_000_000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
pub struct AddCategoryForm { | ||
pub name: String, | ||
pub icon: Option<String>, | ||
} | ||
|
||
pub type DeleteCategoryForm = AddCategoryForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod fixtures; | ||
pub mod forms; | ||
pub mod responses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use serde::Deserialize; | ||
|
||
#[derive(Deserialize)] | ||
pub struct AddedCategoryResponse { | ||
pub data: String, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct ListResponse { | ||
pub data: Vec<ListItem>, | ||
} | ||
|
||
#[derive(Deserialize, Debug, PartialEq)] | ||
pub struct ListItem { | ||
pub category_id: i64, | ||
pub name: String, | ||
pub num_torrents: i64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod about; | ||
pub mod category; | ||
pub mod root; | ||
pub mod settings; | ||
pub mod torrent; | ||
pub mod user; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
use super::Settings; | ||
|
||
pub type UpdateSettingsForm = Settings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
pub mod form; | ||
pub mod responses; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Settings { | ||
pub website: Website, | ||
pub tracker: Tracker, | ||
pub net: Net, | ||
pub auth: Auth, | ||
pub database: Database, | ||
pub mail: Mail, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Website { | ||
pub name: String, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Tracker { | ||
pub url: String, | ||
pub mode: String, | ||
pub api_url: String, | ||
pub token: String, | ||
pub token_valid_seconds: u64, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Net { | ||
pub port: u64, | ||
pub base_url: Option<String>, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Auth { | ||
pub email_on_signup: String, | ||
pub min_password_length: u64, | ||
pub max_password_length: u64, | ||
pub secret_key: String, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Database { | ||
pub connect_url: String, | ||
pub torrent_info_update_interval: u64, | ||
} | ||
|
||
#[derive(Deserialize, Serialize, PartialEq, Debug)] | ||
pub struct Mail { | ||
pub email_verification_enabled: bool, | ||
pub from: String, | ||
pub reply_to: String, | ||
pub username: String, | ||
pub password: String, | ||
pub server: String, | ||
pub port: u64, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use serde::Deserialize; | ||
|
||
use super::Settings; | ||
|
||
#[derive(Deserialize)] | ||
pub struct AllSettingsResponse { | ||
pub data: Settings, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct PublicSettingsResponse { | ||
pub data: Public, | ||
} | ||
|
||
#[derive(Deserialize, PartialEq, Debug)] | ||
pub struct Public { | ||
pub website_name: String, | ||
pub tracker_url: String, | ||
pub tracker_mode: String, | ||
pub email_on_signup: String, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct SiteNameResponse { | ||
pub data: String, | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod asserts; | ||
pub mod file; | ||
pub mod fixtures; | ||
pub mod forms; | ||
pub mod requests; | ||
pub mod responses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub type TorrentId = i64; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use rand::Rng; | ||
|
||
use crate::common::contexts::user::forms::RegistrationForm; | ||
|
||
pub fn random_user_registration() -> RegistrationForm { | ||
let user_id = random_user_id(); | ||
RegistrationForm { | ||
username: format!("username_{user_id}"), | ||
email: Some(format!("email_{user_id}@email.com")), | ||
password: "password".to_string(), | ||
confirm_password: "password".to_string(), | ||
} | ||
} | ||
|
||
fn random_user_id() -> u64 { | ||
let mut rng = rand::thread_rng(); | ||
rng.gen_range(0..1_000_000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use serde::Serialize; | ||
|
||
#[derive(Clone, Serialize)] | ||
pub struct RegistrationForm { | ||
pub username: String, | ||
pub email: Option<String>, | ||
pub password: String, | ||
pub confirm_password: String, | ||
} | ||
|
||
pub type RegisteredUser = RegistrationForm; | ||
|
||
#[derive(Serialize)] | ||
pub struct LoginForm { | ||
pub login: String, | ||
pub password: String, | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct TokenVerificationForm { | ||
pub token: String, | ||
} | ||
|
||
#[derive(Serialize)] | ||
pub struct TokenRenewalForm { | ||
pub token: String, | ||
} | ||
|
||
pub struct Username { | ||
pub value: String, | ||
} | ||
|
||
impl Username { | ||
pub fn new(value: String) -> Self { | ||
Self { value } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod fixtures; | ||
pub mod forms; | ||
pub mod responses; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use serde::Deserialize; | ||
|
||
#[derive(Deserialize)] | ||
pub struct SuccessfulLoginResponse { | ||
pub data: LoggedInUserData, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct LoggedInUserData { | ||
pub token: String, | ||
pub username: String, | ||
pub admin: bool, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct TokenVerifiedResponse { | ||
pub data: String, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct BannedUserResponse { | ||
pub data: String, | ||
} | ||
|
||
#[derive(Deserialize)] | ||
pub struct TokenRenewalResponse { | ||
pub data: TokenRenewalData, | ||
} | ||
|
||
#[derive(Deserialize, PartialEq, Debug)] | ||
pub struct TokenRenewalData { | ||
pub token: String, | ||
pub username: String, | ||
pub admin: bool, | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod asserts; | ||
pub mod client; | ||
pub mod connection_info; | ||
pub mod contexts; | ||
pub mod http; | ||
pub mod responses; |
File renamed without changes.
3 changes: 2 additions & 1 deletion
3
tests/e2e/contexts/about.rs → tests/e2e/contexts/about/contract.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod contract; |
Oops, something went wrong.