change add_owners to return a string and transmit the status message passed from...
authorNatalie Boehm <nmb56@pitt.edu>
Wed, 27 Sep 2017 19:08:17 +0000 (15:08 -0400)
committerNatalie Boehm <nmb56@pitt.edu>
Wed, 27 Sep 2017 19:08:17 +0000 (15:08 -0400)
src/crates-io/lib.rs

index 56ff3b275f8ea08b16083a7449e29e626d88c6c8..c2a8458600fea7d645188cd160ed559d979a40e5 100644 (file)
@@ -116,6 +116,7 @@ pub struct Warnings {
 }
 
 #[derive(Deserialize)] struct R { ok: bool }
+#[derive(Deserialize)] struct OwnerResponse { ok: String }
 #[derive(Deserialize)] struct ApiErrorList { errors: Vec<ApiError> }
 #[derive(Deserialize)] struct ApiError { detail: String }
 #[derive(Serialize)] struct OwnersReq<'a> { users: &'a [&'a str] }
@@ -141,16 +142,14 @@ impl Registry {
         let body = serde_json::to_string(&OwnersReq { users: owners })?;
         let body = self.put(format!("/crates/{}/owners", krate),
                                  body.as_bytes())?;
-        //assert!(serde_json::from_str::<R>(&body)?.ok);
-        //Ok(())
-        Ok(body)
+        Ok(serde_json::from_str::<OwnerResponse>(&body)?.ok)
     }
 
     pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()> {
         let body = serde_json::to_string(&OwnersReq { users: owners })?;
         let body = self.delete(format!("/crates/{}/owners", krate),
                                     Some(body.as_bytes()))?;
-        assert!(serde_json::from_str::<R>(&body)?.ok);
+        serde_json::from_str::<OwnerResponse>(&body)?;
         Ok(())
     }