From b70193d9d0616fa296f302895f76f4453e95d950 Mon Sep 17 00:00:00 2001 From: Tyler Green Date: Fri, 15 Sep 2023 15:23:27 -0400 Subject: [PATCH] Add use_dependencies feature flag --- example-app/Cargo.toml | 4 ++++ example-app/README.md | 4 ++++ example-app/src/api.rs | 2 ++ 3 files changed, 10 insertions(+) diff --git a/example-app/Cargo.toml b/example-app/Cargo.toml index 5bda76e..a183bcb 100644 --- a/example-app/Cargo.toml +++ b/example-app/Cargo.toml @@ -14,9 +14,13 @@ serde_json = "1.0.103" tokio = { version = "1.29.1", features = ["macros", "rt-multi-thread"] } tower = "0.4.13" ureq = "2.7.1" +mime = { version = "0.3.17", optional = true } [build-dependencies] prost-build = "0.12" [dev-dependencies] mockito = "1.1.0" + +[features] +use_dependencies = ["mime"] diff --git a/example-app/README.md b/example-app/README.md index 18e12d8..cf078c2 100644 --- a/example-app/README.md +++ b/example-app/README.md @@ -28,6 +28,10 @@ axum::Server::bind(&address) cargo test cargo run ``` +These commands include a few (and hopefully growing number of) re-implemented library crates. I challenged myself to maintain the same interface and learn how these libraries work. To run with the original dependencies, this works. +``` +cargo test --features "use_dependencies" +``` ## Sample Feed ``` diff --git a/example-app/src/api.rs b/example-app/src/api.rs index 4fe9852..85c0d60 100644 --- a/example-app/src/api.rs +++ b/example-app/src/api.rs @@ -136,7 +136,9 @@ async fn list_handler(state: State) -> impl IntoResponse { #[cfg(test)] mod api_tests { + #[cfg(not(feature = "use_dependencies"))] use crate::deps::mime; + use crate::fetcher::Feed; use crate::scheduler_interface::{SchedulerInterface, TaskSender}; use tulsa::AsyncTask;