From 1ca13bb0ae89545ab622e51f6a6c94d9a0c567cf Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 6 Jun 2024 18:29:37 +0100 Subject: [PATCH] refactor: create git-test crate --- Cargo.toml | 2 ++ crates/forge-forgejo/Cargo.toml | 1 + crates/forge-forgejo/src/tests.rs | 9 ++------- crates/git/test/Cargo.toml | 18 ++++++++++++++++++ crates/git/test/src/given.rs | 9 +++++++++ crates/git/test/src/lib.rs | 1 + 6 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 crates/git/test/Cargo.toml create mode 100644 crates/git/test/src/given.rs create mode 100644 crates/git/test/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 619cf2c..fbcfd2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "crates/config", "crates/config/test", "crates/git", + "crates/git/test", "crates/forge", "crates/forge-forgejo", "crates/forge-github", @@ -27,6 +28,7 @@ git-next-server = { path = "crates/server" } git-next-config = { path = "crates/config" } git-next-config-test = { path = "crates/config/test" } git-next-git = { path = "crates/git" } +git-next-git-test = { path = "crates/git/test" } git-next-forge = { path = "crates/forge" } git-next-forge-forgejo = { path = "crates/forge-forgejo" } git-next-forge-github = { path = "crates/forge-github" } diff --git a/crates/forge-forgejo/Cargo.toml b/crates/forge-forgejo/Cargo.toml index 09c7caa..8a31124 100644 --- a/crates/forge-forgejo/Cargo.toml +++ b/crates/forge-forgejo/Cargo.toml @@ -40,6 +40,7 @@ tokio = { workspace = true } [dev-dependencies] # Testing git-next-config-test = { workspace = true } +git-next-git-test = { workspace = true } assert2 = { workspace = true } rand = { workspace = true } diff --git a/crates/forge-forgejo/src/tests.rs b/crates/forge-forgejo/src/tests.rs index dd751df..3a7133d 100644 --- a/crates/forge-forgejo/src/tests.rs +++ b/crates/forge-forgejo/src/tests.rs @@ -569,6 +569,8 @@ mod forgejo { } mod given { pub use git_next_config_test::given::*; + pub use git_next_git_test::given::*; + use std::collections::HashMap; use kxio::network::{MockNetwork, StatusCode}; @@ -644,13 +646,6 @@ mod forgejo { headers } - pub fn a_commit() -> git::Commit { - git::Commit::new( - git::commit::Sha::new(a_name()), - git::commit::Message::new(a_name()), - ) - } - pub fn a_forgejo_forge( repo_details: &git::RepoDetails, net: impl Into, diff --git a/crates/git/test/Cargo.toml b/crates/git/test/Cargo.toml new file mode 100644 index 0000000..4f294d1 --- /dev/null +++ b/crates/git/test/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "git-next-git-test" +version = { workspace = true } +edition = { workspace = true } + +[dependencies] +git-next-git = { workspace = true } +git-next-config-test = { workspace = true } + +rand = { workspace = true } +kxio = { workspace = true } +# serde_json = { workspace = true } + +[lints.clippy] +nursery = { level = "warn", priority = -1 } +# pedantic = "warn" +unwrap_used = "warn" +expect_used = "warn" diff --git a/crates/git/test/src/given.rs b/crates/git/test/src/given.rs new file mode 100644 index 0000000..0b538c6 --- /dev/null +++ b/crates/git/test/src/given.rs @@ -0,0 +1,9 @@ +use git_next_config_test::given::a_name; +use git_next_git as git; + +pub fn a_commit() -> git::Commit { + git::Commit::new( + git::commit::Sha::new(a_name()), + git::commit::Message::new(a_name()), + ) +} diff --git a/crates/git/test/src/lib.rs b/crates/git/test/src/lib.rs new file mode 100644 index 0000000..a3b940e --- /dev/null +++ b/crates/git/test/src/lib.rs @@ -0,0 +1 @@ +pub mod given;