mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
add test case for --log-json
This commit is contained in:
parent
1418aeadad
commit
a719097611
1 changed files with 20 additions and 0 deletions
|
@ -1629,6 +1629,26 @@ def test_list_json(self):
|
|||
assert file1['path'] == 'input/file1'
|
||||
assert file1['sha256'] == 'b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b'
|
||||
|
||||
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)
|
||||
messages[msg['type']] = msg
|
||||
|
||||
file_status = messages['file_status']
|
||||
assert 'status' in file_status
|
||||
assert file_status['path'].startswith('input')
|
||||
|
||||
log_message = messages['log_message']
|
||||
assert isinstance(log_message['time'], float)
|
||||
assert log_message['levelname'] == 'DEBUG' # there should only be DEBUG messages
|
||||
assert log_message['name'].startswith('borg.')
|
||||
assert isinstance(log_message['message'], str)
|
||||
|
||||
def _get_sizes(self, compression, compressible, size=10000):
|
||||
if compressible:
|
||||
contents = b'X' * size
|
||||
|
|
Loading…
Reference in a new issue