Skip to content

Commit f2318db

Browse files
committed
tests/util: Adjust add/remove_owner() fns return type
1 parent 24ecfa8 commit f2318db

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/tests/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ pub struct OkBool {
8686
ok: bool,
8787
}
8888

89+
#[derive(Deserialize, Debug)]
90+
pub struct OwnerResp {
91+
// server must include `ok: true` to support old cargo clients
92+
ok: bool,
93+
msg: String,
94+
}
95+
8996
fn new_user(login: &str) -> NewUser<'_> {
9097
NewUser {
9198
gh_id: next_gh_id(),

src/tests/routes/crates/owners/add.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::models::token::{CrateScope, EndpointScope};
22
use crate::tests::builders::CrateBuilder;
33
use crate::tests::owners::expire_invitation;
44
use crate::tests::util::{RequestHelper, TestApp};
5+
use crate::tests::OwnerResp;
56
use http::StatusCode;
67
use insta::assert_snapshot;
78

@@ -20,12 +21,6 @@ async fn test_cargo_invite_owners() {
2021
struct OwnerReq {
2122
owners: Option<Vec<String>>,
2223
}
23-
#[derive(Deserialize, Debug)]
24-
struct OwnerResp {
25-
// server must include `ok: true` to support old cargo clients
26-
ok: bool,
27-
msg: String,
28-
}
2924

3025
let body = serde_json::to_string(&OwnerReq {
3126
owners: Some(vec![new_user.as_model().gh_login.clone()]),

src/tests/util.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use crate::middleware::session;
2323
use crate::models::{ApiToken, CreatedApiToken, User};
2424
use crate::tests::{
25-
CategoryListResponse, CategoryResponse, CrateList, CrateResponse, GoodCrate, OkBool,
25+
CategoryListResponse, CategoryResponse, CrateList, CrateResponse, GoodCrate, OwnerResp,
2626
OwnersResponse, VersionResponse,
2727
};
2828

@@ -223,7 +223,7 @@ pub trait RequestHelper {
223223
}
224224

225225
/// Add to the specified crate the specified owners.
226-
async fn add_named_owners<T>(&self, krate_name: &str, owners: &[T]) -> Response<OkBool>
226+
async fn add_named_owners<T>(&self, krate_name: &str, owners: &[T]) -> Response<OwnerResp>
227227
where
228228
T: serde::Serialize,
229229
{
@@ -233,19 +233,19 @@ pub trait RequestHelper {
233233
}
234234

235235
/// Add a single owner to the specified crate.
236-
async fn add_named_owner(&self, krate_name: &str, owner: &str) -> Response<OkBool> {
236+
async fn add_named_owner(&self, krate_name: &str, owner: &str) -> Response<OwnerResp> {
237237
self.add_named_owners(krate_name, &[owner]).await
238238
}
239239

240240
/// Remove from the specified crate the specified owners.
241-
async fn remove_named_owners(&self, krate_name: &str, owners: &[&str]) -> Response<OkBool> {
241+
async fn remove_named_owners(&self, krate_name: &str, owners: &[&str]) -> Response<OwnerResp> {
242242
let url = format!("/api/v1/crates/{krate_name}/owners");
243243
let body = json!({ "owners": owners }).to_string();
244244
self.delete_with_body(&url, body).await
245245
}
246246

247247
/// Remove a single owner to the specified crate.
248-
async fn remove_named_owner(&self, krate_name: &str, owner: &str) -> Response<OkBool> {
248+
async fn remove_named_owner(&self, krate_name: &str, owner: &str) -> Response<OwnerResp> {
249249
self.remove_named_owners(krate_name, &[owner]).await
250250
}
251251
}

0 commit comments

Comments
 (0)