diff --git a/Cargo.lock b/Cargo.lock index 600a949..538e888 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -289,6 +289,12 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + [[package]] name = "either" version = "1.10.0" @@ -331,6 +337,7 @@ dependencies = [ "axum 0.7.4", "clap", "dotenv", + "mockall", "prost", "tokio", "tonic", @@ -354,6 +361,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + [[package]] name = "futures-channel" version = "0.3.28" @@ -750,6 +763,33 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mockall" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43766c2b5203b10de348ffe19f7e54564b64f3d6018ff7648d1e2d6d3a0f0a48" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cbce79ec385a1d4f54baa90a76401eb15d9cab93685f62e7e9f942aa00ae2" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "multimap" version = "0.8.3" @@ -865,6 +905,32 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +[[package]] +name = "predicates" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +dependencies = [ + "anstyle", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "prettyplease" version = "0.2.16" @@ -1186,6 +1252,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + [[package]] name = "thread_local" version = "1.1.7" diff --git a/crates/flux-releaser/Cargo.toml b/crates/flux-releaser/Cargo.toml index 157b5c9..71c66ea 100644 --- a/crates/flux-releaser/Cargo.toml +++ b/crates/flux-releaser/Cargo.toml @@ -16,3 +16,6 @@ tonic = "0.11.0" [build-dependencies] tonic-build = "0.11.0" + +[dev-dependencies] +mockall = "0.12.1" diff --git a/crates/flux-releaser/src/main.rs b/crates/flux-releaser/src/main.rs index bda7699..fe619bd 100644 --- a/crates/flux-releaser/src/main.rs +++ b/crates/flux-releaser/src/main.rs @@ -7,6 +7,8 @@ mod grpc; mod app; +mod services; + #[tokio::main] async fn main() -> anyhow::Result<()> { dotenv::dotenv().ok(); diff --git a/crates/flux-releaser/src/services.rs b/crates/flux-releaser/src/services.rs new file mode 100644 index 0000000..69311ed --- /dev/null +++ b/crates/flux-releaser/src/services.rs @@ -0,0 +1 @@ +pub mod release_manager; diff --git a/crates/flux-releaser/src/services/release_manager.rs b/crates/flux-releaser/src/services/release_manager.rs new file mode 100644 index 0000000..9711aff --- /dev/null +++ b/crates/flux-releaser/src/services/release_manager.rs @@ -0,0 +1,25 @@ +mod default; +pub mod traits; + +use std::sync::Arc; + +#[derive(Clone)] +pub struct ReleaseManager { + inner: Arc, +} + +impl ReleaseManager { + pub fn get_default() -> Self { + Self { + inner: Arc::new(default::ReleaseManager::new()), + } + } +} + +impl std::ops::Deref for ReleaseManager { + type Target = Arc; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} diff --git a/crates/flux-releaser/src/services/release_manager/default.rs b/crates/flux-releaser/src/services/release_manager/default.rs new file mode 100644 index 0000000..2d9ae42 --- /dev/null +++ b/crates/flux-releaser/src/services/release_manager/default.rs @@ -0,0 +1,11 @@ +use super::traits; + +pub struct ReleaseManager {} + +impl ReleaseManager { + pub fn new() -> Self { + Self {} + } +} + +impl traits::ReleaseManager for ReleaseManager {} diff --git a/crates/flux-releaser/src/services/release_manager/traits.rs b/crates/flux-releaser/src/services/release_manager/traits.rs new file mode 100644 index 0000000..275d272 --- /dev/null +++ b/crates/flux-releaser/src/services/release_manager/traits.rs @@ -0,0 +1,4 @@ +#[cfg(test)] +use mockall::{automock, mock, predicate::*}; +#[cfg_attr(test, automock)] +pub trait ReleaseManager {}