Skip to content

Commit

Permalink
✅ Update failing tests (#295)
Browse files Browse the repository at this point in the history
* Get doctests passing again

* Fix clippy lints

---------

Co-authored-by: Aaron Leopold <[email protected]>
  • Loading branch information
JMicheli and aaronleopold authored Apr 12, 2024
1 parent 17d8526 commit 7b3d4d9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions apps/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod config;
pub mod config;
mod errors;
mod filter;
mod http_server;
mod middleware;
pub mod middleware;
mod routers;
mod utils;

Expand Down
19 changes: 15 additions & 4 deletions apps/server/src/middleware/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,22 @@ async fn handle_basic_auth(
/// ## Example:
///
/// ```rust
/// use axum::{Router, middleware::from_extractor};
/// use axum::{Router, middleware::{from_extractor, from_extractor_with_state}};
/// use stump_core::{Ctx, config::StumpConfig};
/// use stump_server::{
/// middleware::auth::{Auth, ServerOwnerGuard},
/// config::state::AppState
/// };
///
/// Router::new()
/// .layer(from_extractor::<ServerOwnerGuard>())
/// .layer(from_extractor_with_state::<Auth, AppState>(app_state));
/// #[tokio::main]
/// async fn main() {
/// let config = StumpConfig::debug();
/// let ctx = Ctx::new(config).await.arced();
///
/// let router: Router<AppState> = Router::new()
/// .layer(from_extractor::<ServerOwnerGuard>())
/// .layer(from_extractor_with_state::<Auth, AppState>(ctx));
/// }
/// ```
pub struct ServerOwnerGuard;

Expand Down
22 changes: 9 additions & 13 deletions core/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@ impl Ctx {
/// ## Example
/// ```rust
/// use stump_core::{Ctx, config::StumpConfig};
/// use tokio::sync::mpsc::unbounded_channel;
/// use std::sync::Arc;
///
/// #[tokio::main]
/// async fn main() {
/// let (sender, _) = unbounded_channel();
/// let config = StumpConfig::debug();
///
/// let ctx = Ctx::new(config, sender).await;
/// let ctx = Ctx::new(config).await;
/// let arced_ctx = ctx.arced();
/// let ctx_clone = arced_ctx.clone();
///
Expand All @@ -118,18 +116,16 @@ impl Ctx {
///
/// ## Example
/// ```rust
/// use stump_core::{Ctx, config::StumpConfig, event::CoreEvent};
/// use tokio::sync::mpsc::unbounded_channel;
/// use stump_core::{Ctx, config::StumpConfig, CoreEvent};
///
/// #[tokio::main]
/// async fn main() {
/// let (sender, _) = unbounded_channel();
/// let config = StumpConfig::debug();
/// let ctx = Ctx::new(config, sender).await;
/// let ctx = Ctx::new(config).await;
///
/// let event = CoreEvent::JobFailed {
/// job_id: "Gandalf quote".to_string(),
/// message: "When in doubt, follow your nose".to_string(),
/// let event = CoreEvent::CreatedMedia {
/// id: "id_for_the_media".to_string(),
/// series_id: "id_for_its_series".to_string(),
/// };
///
/// let ctx_cpy = ctx.clone();
Expand All @@ -138,9 +134,9 @@ impl Ctx {
/// let received_event = receiver.recv().await;
/// assert_eq!(received_event.is_ok(), true);
/// match received_event.unwrap() {
/// CoreEvent::JobFailed { job_id, message } => {
/// assert_eq!(job_id, "Gandalf quote");
/// assert_eq!(message, "When in doubt, follow your nose");
/// CoreEvent::CreatedMedia { id, series_id } => {
/// assert_eq!(id, "id_for_the_media");
/// assert_eq!(series_id, "id_for_its_series");
/// }
/// _ => unreachable!("Wrong event type received"),
/// }
Expand Down

0 comments on commit 7b3d4d9

Please sign in to comment.