feat: implement user follow/unfollow functionality and thought retrieval by user
- Added follow and unfollow endpoints for users. - Implemented logic to retrieve thoughts by a specific user. - Updated user error handling to include cases for already following and not following. - Created persistence layer for follow relationships. - Enhanced user and thought schemas to support new features. - Added tests for follow/unfollow endpoints and thought retrieval. - Updated frontend to display thoughts and allow posting new thoughts.
This commit is contained in:
29
thoughts-backend/tests/api/main.rs
Normal file
29
thoughts-backend/tests/api/main.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use api::setup_router;
|
||||
use app::persistence::user::create_user;
|
||||
use axum::Router;
|
||||
use models::params::user::CreateUserParams;
|
||||
use sea_orm::DatabaseConnection;
|
||||
use utils::testing::setup_test_db;
|
||||
|
||||
pub struct TestApp {
|
||||
pub router: Router,
|
||||
pub db: DatabaseConnection,
|
||||
}
|
||||
|
||||
pub async fn setup() -> TestApp {
|
||||
let db = setup_test_db("sqlite::memory:")
|
||||
.await
|
||||
.expect("Failed to set up test db");
|
||||
let router = setup_router(db.clone());
|
||||
TestApp { router, db }
|
||||
}
|
||||
|
||||
// Helper to create users for tests
|
||||
pub async fn create_test_user(db: &DatabaseConnection, username: &str) {
|
||||
let params = CreateUserParams {
|
||||
username: username.to_string(),
|
||||
};
|
||||
create_user(db, params)
|
||||
.await
|
||||
.expect("Failed to create test user");
|
||||
}
|
Reference in New Issue
Block a user