MCPcopy Create free account
hub / github.com/bootc-dev/bootc / test_parse_lsblk

Function test_parse_lsblk

crates/blockdev/src/blockdev.rs:752–781  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

750
751 #[test]
752 fn test_parse_lsblk() {
753 let fixture = include_str!("../tests/fixtures/lsblk.json");
754 let devs: DevicesOutput = serde_json::from_str(fixture).unwrap();
755 let dev = devs.blockdevices.into_iter().next().unwrap();
756 // The parent device has no partition number
757 assert_eq!(dev.partn, None);
758 let children = dev.children.as_deref().unwrap();
759 assert_eq!(children.len(), 3);
760 let first_child = &children[0];
761 assert_eq!(first_child.partn, Some(1));
762 assert_eq!(
763 first_child.parttype.as_deref().unwrap(),
764 "21686148-6449-6e6f-744e-656564454649"
765 );
766 assert_eq!(
767 first_child.partuuid.as_deref().unwrap(),
768 "3979e399-262f-4666-aabc-7ab5d3add2f0"
769 );
770 // Verify find_device_by_partno works
771 let part2 = dev.find_device_by_partno(2).unwrap();
772 assert_eq!(part2.partn, Some(2));
773 assert_eq!(part2.parttype.as_deref().unwrap(), ESP);
774 // Verify find_partition_of_esp works
775 let esp = dev.find_partition_of_esp().unwrap();
776 assert_eq!(esp.partn, Some(2));
777 // Verify find_partition_of_bios_boot works (vda1 is BIOS-BOOT)
778 let bios = dev.find_partition_of_bios_boot().unwrap();
779 assert_eq!(bios.partn, Some(1));
780 assert_eq!(bios.parttype.as_deref().unwrap(), BIOS_BOOT);
781 }
782
783 /// Verify that without the udev database, partition type fields are null
784 /// and partition discovery fails. This simulates what happens when bootc

Callers

nothing calls this directly

Calls 5

find_device_by_partnoMethod · 0.80
find_partition_of_espMethod · 0.80
nextMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected