Merge pull request #1972 from Chris-Peterson444/reset-partition-bug

filesystem: reset-partition size bug
This commit is contained in:
Chris Peterson 2024-05-06 12:27:36 -07:00 committed by GitHub
commit c6a1b583de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 1 deletions

View File

@ -1457,7 +1457,8 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
rp_input = layout.get("reset-partition", None)
if rp_input:
reset_partition = True
if isinstance(rp_input, (str, int)):
# bool is a subclass of int -- check for int explicitly
if isinstance(rp_input, str) or type(rp_input) is int:
reset_partition_size = int(human2bytes(rp_input))
log.info(
"autoinstall: will install reset partition "

View File

@ -546,6 +546,27 @@ class TestGuided(IsolatedAsyncioTestCase):
self.assertEqual(None, d1p2.mount)
self.assertEqual(DRY_RUN_RESET_SIZE, d1p2.size)
@parameterized.expand(
(
({}, False, None),
({"reset-partition": True}, True, None),
({"reset-partition": False}, False, None),
({"reset-partition": "12345"}, True, 12345),
({"reset-partition": "10G"}, True, 10737418240),
({"reset-partition": 100000}, True, 100000),
)
)
async def test_rest_partition_size(
self, ai_data, reset_partition, reset_partition_size
):
await self._guided_setup(Bootloader.UEFI, "gpt")
self.controller.guided = mock.AsyncMock()
layout = ai_data | {"name": "direct"}
await self.controller.run_autoinstall_guided(layout)
guided_choice = self.controller.guided.call_args.args[0]
self.assertEqual(guided_choice.reset_partition, reset_partition)
self.assertEqual(guided_choice.reset_partition_size, reset_partition_size)
async def test_guided_direct_BIOS_MSDOS(self):
await self._guided_setup(Bootloader.BIOS, "msdos")
target = GuidedStorageTargetReformat(