Add last couple of missing tests after audit (#303).

This commit is contained in:
Dan Helfman 2025-03-29 14:26:54 -07:00
commit f6929f8891
3 changed files with 24 additions and 4 deletions

4
NEWS
View file

@ -1,6 +1,6 @@
2.0.0.dev0
* #303: Add command-line flags for every borgmatic configuration option. See the
documentation for more information:
* #303: Deprecate the "--override" flag in favor of direct command-line flags for every borgmatic
configuration option. See the documentation for more information:
https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#configuration-overrides
* #303: Add configuration options that serve as defaults for some (but not all) command-line
action flags. For example, each entry in "repositories:" now has an "encryption" option that

View file

@ -1,7 +1,7 @@
def variants(flag_name):
'''
Given an flag name as a string, yield it and any variations that should be complete-able as
well. For instance, for a string like "--foo[0].bar", yield "--foo[0].bar", "--foo[1].bar", ...,
Given a flag name as a string, yield it and any variations that should be complete-able as well.
For instance, for a string like "--foo[0].bar", yield "--foo[0].bar", "--foo[1].bar", ...,
"--foo[9].bar".
'''
if '[0]' in flag_name:

View file

@ -0,0 +1,20 @@
from borgmatic.commands.completion import flag as module
def test_variants_passes_through_non_list_index_flag_name():
assert tuple(module.variants('foo')) == ('foo',)
def test_variants_broadcasts_list_index_flag_name_with_a_range_of_indices():
assert tuple(module.variants('foo[0].bar')) == (
'foo[0].bar',
'foo[1].bar',
'foo[2].bar',
'foo[3].bar',
'foo[4].bar',
'foo[5].bar',
'foo[6].bar',
'foo[7].bar',
'foo[8].bar',
'foo[9].bar',
)