fix(oci): count only paths added by hand in the Modify menu

- Leave the application's own volumes out of the Extra paths count
- Add a regression test for the count
This commit is contained in:
MacRimi
2026-10-17 21:21:30 +02:00
parent 7d17220294
commit 2c8ebcaa9f
2 changed files with 9 additions and 1 deletions
+2 -1
View File
@@ -120,7 +120,8 @@ def modification_options(candidate):
('memory', row(translate('RAM in MiB'), resources['memory_mb'])),
('network', row(translate('Network'),
f"{network.get('bridge', '-')} · {'DHCP' if address == 'dhcp' else address}")),
('paths', row(translate('Extra paths'), len(deployment.get('mounts', [])))),
# Only the paths added by hand: the application's own volumes are not extra.
('paths', row(translate('Extra paths'), sum(1 for m in deployment.get('mounts', []) if m.get('custom')))),
]
if profile.get('shared_directories'):
options.append(('shares', translate('Shared directories')))
+7
View File
@@ -147,6 +147,13 @@ class ModifyMenuTests(unittest.TestCase):
recreation.edit_recreation(record(), ui)
self.assertNotIn('private-test-secret', json.dumps(ui.events))
def test_extra_paths_counts_only_paths_added_by_hand(self, _language):
candidate = record()
self.assertTrue(dict(recreation.modification_options(candidate))['paths'].rstrip().endswith(' 0'))
candidate['deployment']['mounts'].append({'container_path': '/media-extra', 'type': 'host-bind',
'source': '/mnt/media', 'custom': True})
self.assertTrue(dict(recreation.modification_options(candidate))['paths'].rstrip().endswith(' 1'))
def test_optional_categories_follow_the_application_profile(self, _language):
candidate = record()
options = dict(recreation.modification_options(candidate))