Bläddra i källkod

list: add test for handling of --json/--json-lines

Marian Beermann 8 år sedan
förälder
incheckning
be9a94c22c
2 ändrade filer med 6 tillägg och 2 borttagningar
  1. 1 1
      src/borg/archiver.py
  2. 5 1
      src/borg/testsuite/archiver.py

+ 1 - 1
src/borg/archiver.py

@@ -2620,7 +2620,7 @@ class Archiver:
                                help="""specify format for file listing
                                 (default: "{mode} {user:6} {group:6} {size:8d} {isomtime} {path}{extra}{NL}")""")
         subparser.add_argument('--json', action='store_true',
-                               help='Only valid for listing archives. Format output as JSON. '
+                               help='Only valid for listing repository contents. Format output as JSON. '
                                     'The form of --format is ignored, '
                                     'but keys used in it are added to the JSON output. '
                                     'Some keys are always present. Note: JSON can only represent text. '

+ 5 - 1
src/borg/testsuite/archiver.py

@@ -1629,11 +1629,15 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         assert file1['path'] == 'input/file1'
         assert file1['sha256'] == 'b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b'
 
+    def test_list_json_args(self):
+        self.cmd('init', '--encryption=repokey', self.repository_location)
+        self.cmd('list', '--json-lines', self.repository_location, exit_code=2)
+        self.cmd('list', '--json', self.repository_location + '::archive', exit_code=2)
+
     def test_log_json(self):
         self.create_test_files()
         self.cmd('init', '--encryption=repokey', self.repository_location)
         log = self.cmd('create', '--log-json', self.repository_location + '::test', 'input', '--list', '--debug')
-        print(log)
         messages = {}  # type -> message, one of each kind
         for line in log.splitlines():
             msg = json.loads(line)