Skip to content

Commit ce0fbb7

Browse files
committed
github: Use mockall to generate MockGitHubClient implementation
1 parent dd03001 commit ce0fbb7

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ unicode-xid = "=0.2.6"
122122

123123
[dev-dependencies]
124124
bytes = "=1.8.0"
125+
crates_io_github = { path = "crates/crates_io_github", features = ["mock"] }
125126
crates_io_index = { path = "crates/crates_io_index", features = ["testing"] }
126127
crates_io_tarball = { path = "crates/crates_io_tarball", features = ["builder"] }
127128
crates_io_team_repo = { path = "crates/crates_io_team_repo", features = ["mock"] }

crates/crates_io_github/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ edition = "2021"
77
[lints]
88
workspace = true
99

10+
[features]
11+
mock = ["dep:mockall"]
12+
1013
[dependencies]
1114
anyhow = "=1.0.93"
1215
async-trait = "=0.1.83"
16+
mockall = { version = "=0.13.0", optional = true }
1317
oauth2 = { version = "=4.4.2", default-features = false }
1418
reqwest = { version = "=0.12.9", features = ["json"] }
1519
serde = { version = "=1.0.215", features = ["derive"] }

crates/crates_io_github/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use serde::Deserialize;
1616

1717
type Result<T> = std::result::Result<T, GitHubError>;
1818

19+
#[cfg_attr(feature = "mock", mockall::automock)]
1920
#[async_trait]
2021
pub trait GitHubClient: Send + Sync {
2122
async fn current_user(&self, auth: &AccessToken) -> Result<GithubUser>;

0 commit comments

Comments
 (0)