@@ -217,16 +217,26 @@ pub enum UpdateType {
217217 } ,
218218}
219219
220+ #[ derive( Debug , Clone , Deserialize ) ]
221+ #[ serde( rename_all = "camelCase" ) ]
222+ pub struct FailedUpdateResult {
223+ #[ serde( rename = "message" ) ]
224+ pub error_message : String ,
225+ #[ serde( rename = "code" ) ]
226+ pub error_code : String ,
227+ #[ serde( rename = "type" ) ]
228+ pub error_type : String ,
229+ #[ serde( rename = "link" ) ]
230+ pub error_link : String
231+ }
232+
220233#[ derive( Deserialize , Debug , Clone ) ]
221234#[ serde( rename_all = "camelCase" ) ]
222235pub struct ProcessedUpdateResult {
223236 pub update_id : u64 ,
224237 #[ serde( rename = "type" ) ]
225238 pub update_type : UpdateType ,
226- pub error : Option < String > ,
227- pub error_type : Option < String > ,
228- pub error_code : Option < String > ,
229- pub error_link : Option < String > ,
239+ pub error : Option < FailedUpdateResult > ,
230240 pub duration : f64 , // in seconds
231241 pub enqueued_at : String , // TODO deserialize to datetime
232242 pub processed_at : String , // TODO deserialize to datetime
@@ -351,4 +361,15 @@ mod test {
351361
352362 assert ! ( now. elapsed( ) >= sleep_duration) ;
353363 }
364+
365+ #[ async_test]
366+ async fn test_failing_update ( ) {
367+ let client = Client :: new ( "http://localhost:7700" , "masterKey" ) ;
368+ let movies = client. get_or_create ( "movies_wait_for_pending_timeout" ) . await . unwrap ( ) ;
369+ let progress = movies. set_ranking_rules ( [ "wrong_ranking_rule" ] ) . await . unwrap ( ) ;
370+ let status = progress. wait_for_pending_update (
371+ Some ( Duration :: from_millis ( 1 ) ) , Some ( Duration :: from_nanos ( 1 ) )
372+ ) . await . unwrap ( ) ;
373+ assert ! ( matches!( status. unwrap( ) , UpdateStatus :: Failed { .. } ) ) ;
374+ }
354375}
0 commit comments