-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: [#109] extract structs and functions
- Loading branch information
1 parent
80ad41e
commit 652f50b
Showing
8 changed files
with
54 additions
and
19 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
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,20 @@ | ||
use crate::e2e::client::Client; | ||
use crate::e2e::connection_info::anonymous_connection; | ||
|
||
pub struct TestEnv { | ||
pub authority: String, | ||
} | ||
|
||
impl TestEnv { | ||
pub fn guess_client(&self) -> Client { | ||
Client::new(anonymous_connection(&self.authority)) | ||
} | ||
} | ||
|
||
impl Default for TestEnv { | ||
fn default() -> Self { | ||
Self { | ||
authority: "localhost:3000".to_string(), | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
mod asserts; | ||
mod client; | ||
mod connection_info; | ||
pub mod env; | ||
mod http; | ||
mod response; | ||
mod routes; |
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 |
---|---|---|
@@ -1,26 +1,24 @@ | ||
use crate::e2e::asserts::{assert_ok, assert_response_title}; | ||
use crate::e2e::client::Client; | ||
use crate::e2e::connection_info::connection_with_no_token; | ||
use crate::e2e::http::Query; | ||
use crate::e2e::asserts::{assert_response_title, assert_text_ok}; | ||
use crate::e2e::env::TestEnv; | ||
|
||
#[tokio::test] | ||
#[cfg_attr(not(feature = "e2e-tests"), ignore)] | ||
async fn it_should_load_the_about_page_with_information_about_the_api() { | ||
let client = Client::new(connection_with_no_token("localhost:3000")); | ||
let client = TestEnv::default().guess_client(); | ||
|
||
let response = client.get("about", Query::empty()).await; | ||
let response = client.about().await; | ||
|
||
assert_ok(&response); | ||
assert_text_ok(&response); | ||
assert_response_title(&response, "About"); | ||
} | ||
|
||
#[tokio::test] | ||
#[cfg_attr(not(feature = "e2e-tests"), ignore)] | ||
async fn it_should_load_the_license_page_at_the_api_entrypoint() { | ||
let client = Client::new(connection_with_no_token("localhost:3000")); | ||
let client = TestEnv::default().guess_client(); | ||
|
||
let response = client.get("about/license", Query::empty()).await; | ||
let response = client.license().await; | ||
|
||
assert_ok(&response); | ||
assert_text_ok(&response); | ||
assert_response_title(&response, "Licensing"); | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod about; | ||
|
||
pub mod root; |
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
use crate::e2e::asserts::{assert_ok, assert_response_title}; | ||
use crate::e2e::client::Client; | ||
use crate::e2e::connection_info::connection_with_no_token; | ||
use crate::e2e::http::Query; | ||
use crate::e2e::asserts::{assert_response_title, assert_text_ok}; | ||
use crate::e2e::env::TestEnv; | ||
|
||
#[tokio::test] | ||
#[cfg_attr(not(feature = "e2e-tests"), ignore)] | ||
async fn it_should_load_the_about_page_at_the_api_entrypoint() { | ||
let client = Client::new(connection_with_no_token("localhost:3000")); | ||
let client = TestEnv::default().guess_client(); | ||
|
||
let response = client.get("", Query::empty()).await; | ||
let response = client.root().await; | ||
|
||
assert_ok(&response); | ||
assert_text_ok(&response); | ||
assert_response_title(&response, "About"); | ||
} |