@@ -316,4 +316,49 @@ mod tests {
316
316
assert ! ( Store :: from_str( "OstrEeContAiner" , true ) . is_ok( ) ) ;
317
317
assert ! ( Store :: from_str( "invalid" , true ) . is_err( ) ) ;
318
318
}
319
+
320
+ #[ test]
321
+ fn test_host_filter_to_slot ( ) {
322
+ fn create_host ( ) -> Host {
323
+ let mut host = Host :: default ( ) ;
324
+ host. status . staged = Some ( default_boot_entry ( ) ) ;
325
+ host. status . booted = Some ( default_boot_entry ( ) ) ;
326
+ host. status . rollback = Some ( default_boot_entry ( ) ) ;
327
+ host
328
+ }
329
+
330
+ fn default_boot_entry ( ) -> BootEntry {
331
+ BootEntry {
332
+ image : None ,
333
+ cached_update : None ,
334
+ incompatible : false ,
335
+ pinned : false ,
336
+ store : None ,
337
+ ostree : None ,
338
+ }
339
+ }
340
+
341
+ fn assert_host_state (
342
+ host : & Host ,
343
+ staged : Option < BootEntry > ,
344
+ booted : Option < BootEntry > ,
345
+ rollback : Option < BootEntry > ,
346
+ ) {
347
+ assert_eq ! ( host. status. staged, staged) ;
348
+ assert_eq ! ( host. status. booted, booted) ;
349
+ assert_eq ! ( host. status. rollback, rollback) ;
350
+ }
351
+
352
+ let mut host = create_host ( ) ;
353
+ host. filter_to_slot ( Slot :: Staged ) ;
354
+ assert_host_state ( & host, Some ( default_boot_entry ( ) ) , None , None ) ;
355
+
356
+ let mut host = create_host ( ) ;
357
+ host. filter_to_slot ( Slot :: Booted ) ;
358
+ assert_host_state ( & host, None , Some ( default_boot_entry ( ) ) , None ) ;
359
+
360
+ let mut host = create_host ( ) ;
361
+ host. filter_to_slot ( Slot :: Rollback ) ;
362
+ assert_host_state ( & host, None , None , Some ( default_boot_entry ( ) ) ) ;
363
+ }
319
364
}
0 commit comments