mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
list: add test for handling of --json/--json-lines
This commit is contained in:
parent
a719097611
commit
be9a94c22c
2 changed files with 6 additions and 2 deletions
|
@ -2620,7 +2620,7 @@ def process_epilog(epilog):
|
|||
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. '
|
||||
|
|
|
@ -1629,11 +1629,15 @@ def test_list_json(self):
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue