Profile update tests
This commit is contained in:
@@ -375,6 +375,30 @@ impl TestApp {
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn edit_profile<Body>(&self, body: &Body) -> reqwest::Response
|
||||
where
|
||||
Body: serde::Serialize,
|
||||
{
|
||||
self.api_client
|
||||
.put(format!("{}/users/edit", self.address))
|
||||
.form(body)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_profile(&self, username: &str) -> reqwest::Response {
|
||||
self.api_client
|
||||
.get(format!("{}/users/{}", self.address, username))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_profile_html(&self, username: &str) -> String {
|
||||
self.get_profile(username).await.text().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn post_create_post<Body>(&self, body: &Body) -> reqwest::Response
|
||||
where
|
||||
Body: serde::Serialize,
|
||||
@@ -426,6 +450,14 @@ impl TestApp {
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_user_id(&self, username: &str) -> Uuid {
|
||||
let record = sqlx::query!("SELECT user_id FROM users WHERE username = $1", username)
|
||||
.fetch_one(&self.connection_pool)
|
||||
.await
|
||||
.unwrap();
|
||||
record.user_id
|
||||
}
|
||||
}
|
||||
|
||||
pub fn assert_is_redirect_to(response: &reqwest::Response, location: &str) {
|
||||
|
||||
Reference in New Issue
Block a user