diff --git a/src/appview/download_tests.rs b/src/appview/download_tests.rs index 82c3e6e..8217e68 100644 --- a/src/appview/download_tests.rs +++ b/src/appview/download_tests.rs @@ -1,6 +1,5 @@ use super::test_support::*; - #[tokio::test] async fn get_part_file_missing_uri_is_bad_request() { let state = state().await; diff --git a/src/appview/proxy_tests.rs b/src/appview/proxy_tests.rs index 3f802cb..45a120d 100644 --- a/src/appview/proxy_tests.rs +++ b/src/appview/proxy_tests.rs @@ -1,10 +1,12 @@ use super::test_support::*; +use crate::indexing::projection::{ + ProjectionEvent, ProjectionInput, project_eager_record, project_event, +}; use jacquard_common::deps::bytes::Bytes; use jacquard_common::error::{AuthError, ClientError}; use jacquard_common::types::value::{Data, to_data}; use jacquard_common::xrpc::Response as XrpcResponse; use polymodel_api::com_atproto::repo::get_record::GetRecordResponse; -use crate::indexing::projection::{ProjectionEvent, ProjectionInput, project_eager_record, project_event}; #[test] fn parse_record_ref_accepts_valid_create_response() { @@ -156,7 +158,6 @@ async fn forward_xrpc_preserves_error_status_body_and_json_content_type() { // eager projection, structural allowlist, and session gating. // --------------------------------------------------------------------------- - #[tokio::test] async fn forward_xrpc_passes_through_success_body() { let resp = crate::appview::proxy::forward_xrpc::(Ok(XrpcResponse::new( diff --git a/src/appview/read_tests.rs b/src/appview/read_tests.rs index 0b23588..6e6bfbc 100644 --- a/src/appview/read_tests.rs +++ b/src/appview/read_tests.rs @@ -1,5 +1,5 @@ use super::test_support::*; - +use super::views; #[tokio::test] async fn get_thing_hydrates_thing_with_ordered_models_and_record() { diff --git a/src/appview/session_tests.rs b/src/appview/session_tests.rs index 67a830e..31ed4a0 100644 --- a/src/appview/session_tests.rs +++ b/src/appview/session_tests.rs @@ -1,5 +1,5 @@ use super::test_support::*; - +use super::views; #[tokio::test] async fn get_session_route_returns_unauthenticated_marker() { @@ -149,7 +149,10 @@ async fn fullstack_context_feed_helper_supports_following() { parts.extensions.insert(state); let feed = FullstackContext::new(parts) - .scope(crate::appview::ssr::get_feed_from_fullstack_context("following", 24)) + .scope(crate::appview::ssr::get_feed_from_fullstack_context( + "following", + 24, + )) .await .unwrap(); diff --git a/src/appview/test_support.rs b/src/appview/test_support.rs index 77205fb..1ea7dcb 100644 --- a/src/appview/test_support.rs +++ b/src/appview/test_support.rs @@ -23,7 +23,9 @@ pub(crate) use jacquard_common::session::SessionKey; pub(crate) use jacquard_common::types::datetime::Datetime; pub(crate) use jacquard_common::types::string::Did; pub(crate) use polymodel_api::space_polymodel::actor::ProfileViewUnion; -pub(crate) use polymodel_api::space_polymodel::actor::get_session::{GetSessionOutput, SessionView}; +pub(crate) use polymodel_api::space_polymodel::actor::get_session::{ + GetSessionOutput, SessionView, +}; pub(crate) use serde_json::json; pub(crate) use sqlx::SqlitePool; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; @@ -33,7 +35,6 @@ pub(crate) use tower::ServiceExt; pub(crate) use super::error::AppError; pub(crate) use super::state::AppState; -pub(crate) use super::views; pub(crate) const DID_A: &str = "did:plc:aaaaaaaaaaaaaaaaaaaaaaaa"; pub(crate) const DID_B: &str = "did:plc:bbbbbbbbbbbbbbbbbbbbbbbb"; @@ -78,7 +79,11 @@ pub(crate) fn client_session(account_did: &str, session_id: &str) -> ClientSessi } } -async pub(crate) fn seed_oauth_session(state: &AppState, account_did: &str, session_id: &str) -> SessionKey { +pub(crate) async fn seed_oauth_session( + state: &AppState, + account_did: &str, + session_id: &str, +) -> SessionKey { let data = client_session(account_did, session_id); let key = SessionKey::new(data.account_did.clone(), data.session_id.clone()); state @@ -91,7 +96,7 @@ async pub(crate) fn seed_oauth_session(state: &AppState, account_did: &str, sess key } -async pub(crate) fn pool() -> SqlitePool { +pub(crate) async fn pool() -> SqlitePool { let options = SqliteConnectOptions::from_str("sqlite::memory:").unwrap(); let pool = SqlitePoolOptions::new() .max_connections(1) @@ -102,7 +107,7 @@ async pub(crate) fn pool() -> SqlitePool { pool } -async pub(crate) fn state() -> AppState { +pub(crate) async fn state() -> AppState { let pool = pool().await; let bootstrap = crate::oauth::bootstrap_oauth(pool.clone(), Some("http://localhost")) .expect("ephemeral OAuth bootstrap for tests"); @@ -132,7 +137,7 @@ pub(crate) fn strong_ref(uri: &str) -> serde_json::Value { json!({ "uri": uri, "cid": "bafyreicid" }) } -async pub(crate) fn seed_thing( +pub(crate) async fn seed_thing( pool: &SqlitePool, did: &str, rkey: &str, @@ -190,7 +195,7 @@ async pub(crate) fn seed_thing( uri } -async pub(crate) fn set_thing_created_at(pool: &SqlitePool, uri: &str, created_at: i64) { +pub(crate) async fn set_thing_created_at(pool: &SqlitePool, uri: &str, created_at: i64) { sqlx::query("UPDATE things SET created_at = ? WHERE uri = ?") .bind(created_at) .bind(uri) @@ -199,7 +204,7 @@ async pub(crate) fn set_thing_created_at(pool: &SqlitePool, uri: &str, created_a .unwrap(); } -async pub(crate) fn seed_model( +pub(crate) async fn seed_model( pool: &SqlitePool, did: &str, rkey: &str, @@ -245,7 +250,7 @@ async pub(crate) fn seed_model( uri } -async pub(crate) fn seed_part(pool: &SqlitePool, did: &str, rkey: &str, name: &str) -> String { +pub(crate) async fn seed_part(pool: &SqlitePool, did: &str, rkey: &str, name: &str) -> String { let uri = format!("at://{did}/space.polymodel.library.part/{rkey}"); let now = chrono::Utc::now() .timestamp_nanos_opt() @@ -274,7 +279,7 @@ async pub(crate) fn seed_part(pool: &SqlitePool, did: &str, rkey: &str, name: &s uri } -async pub(crate) fn seed_identity(pool: &SqlitePool, did: &str, handle: &str) { +pub(crate) async fn seed_identity(pool: &SqlitePool, did: &str, handle: &str) { sqlx::query( "INSERT INTO identities (did, handle, updated_at) VALUES (?, ?, ?) \ ON CONFLICT(did) DO UPDATE SET handle = excluded.handle", @@ -291,7 +296,7 @@ async pub(crate) fn seed_identity(pool: &SqlitePool, did: &str, handle: &str) { .unwrap(); } -async pub(crate) fn seed_profile(pool: &SqlitePool, did: &str, display: &str) { +pub(crate) async fn seed_profile(pool: &SqlitePool, did: &str, display: &str) { let avatar = blob("bafkreiavatar").to_string(); sqlx::query( r#"INSERT INTO profiles (did, display_name, description, avatar_json, default_license, @@ -314,7 +319,7 @@ async pub(crate) fn seed_profile(pool: &SqlitePool, did: &str, display: &str) { .unwrap(); } -async pub(crate) fn seed_list(pool: &SqlitePool, did: &str, rkey: &str, name: &str) -> String { +pub(crate) async fn seed_list(pool: &SqlitePool, did: &str, rkey: &str, name: &str) -> String { let uri = format!("at://{did}/space.polymodel.graph.list/{rkey}"); let now = chrono::Utc::now() .timestamp_nanos_opt() @@ -342,7 +347,7 @@ async pub(crate) fn seed_list(pool: &SqlitePool, did: &str, rkey: &str, name: &s uri } -async pub(crate) fn body_text(resp: axum::response::Response) -> String { +pub(crate) async fn body_text(resp: axum::response::Response) -> String { let bytes = axum::body::to_bytes(resp.into_body(), 1 << 20) .await .unwrap(); diff --git a/src/appview/tests.rs b/src/appview/tests.rs index ff781f9..d7c8903 100644 --- a/src/appview/tests.rs +++ b/src/appview/tests.rs @@ -4,12 +4,17 @@ pub(super) use super::{actor, error, proxy, router, ssr, state, views}; #[cfg(test)] -mod test_support; +#[path = "download_tests.rs"] +mod download_tests; +#[cfg(test)] +#[path = "proxy_tests.rs"] +mod proxy_tests; #[cfg(test)] +#[path = "read_tests.rs"] mod read_tests; #[cfg(test)] +#[path = "session_tests.rs"] mod session_tests; #[cfg(test)] -mod proxy_tests; -#[cfg(test)] -mod download_tests; +#[path = "test_support.rs"] +mod test_support;