File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -298,8 +298,21 @@ impl Registry {
298298
299299 pub fn unyank ( & mut self , krate : & str , version : & str ) -> Result < ( ) > {
300300 let body = self . put ( & format ! ( "/crates/{}/{}/unyank" , krate, version) , & [ ] ) ?;
301- assert ! ( serde_json:: from_str:: <R >( & body) ?. ok) ;
302- Ok ( ( ) )
301+ let body = if body. is_empty ( ) {
302+ r#"{"ok":false}"# . parse ( ) ?
303+ } else {
304+ body
305+ } ;
306+ match serde_json:: from_str :: < R > ( & body) {
307+ Ok ( response) => {
308+ if response. ok {
309+ Ok ( ( ) )
310+ } else {
311+ bail ! ( "ok is false in response body" )
312+ }
313+ }
314+ _ => bail ! ( "failed to parse response body" ) ,
315+ }
303316 }
304317
305318 fn put ( & mut self , path : & str , b : & [ u8 ] ) -> Result < String > {
Original file line number Diff line number Diff line change @@ -35,4 +35,17 @@ fn simple() {
3535 p. cargo ( "yank --vers 0.0.1 --index" )
3636 . arg ( registry_url ( ) . to_string ( ) )
3737 . run ( ) ;
38+
39+ p. cargo ( "yank --undo --vers 0.0.1 --index" )
40+ . arg ( registry_url ( ) . to_string ( ) )
41+ . with_status ( 101 )
42+ . with_stderr (
43+ " Updating `[..]` index
44+ Unyank foo:0.0.1
45+ error: failed to undo a yank
46+
47+ Caused by:
48+ ok is false in response body" ,
49+ )
50+ . run ( ) ;
3851}
You can’t perform that action at this time.
0 commit comments