Browse Source

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

Dan Helfman 2 tháng trước cách đây
mục cha
commit
f6929f8891
3 tập tin đã thay đổi với 24 bổ sung4 xóa
  1. 2 2
      NEWS
  2. 2 2
      borgmatic/commands/completion/flag.py
  3. 20 0
      tests/unit/commands/completion/test_flag.py

+ 2 - 2
NEWS

@@ -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

+ 2 - 2
borgmatic/commands/completion/flag.py

@@ -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:

+ 20 - 0
tests/unit/commands/completion/test_flag.py

@@ -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',
+    )