mirror of https://github.com/borgbackup/borg.git
add test case for --log-json
This commit is contained in:
parent
1418aeadad
commit
a719097611
|
@ -1629,6 +1629,26 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
assert file1['path'] == 'input/file1'
|
assert file1['path'] == 'input/file1'
|
||||||
assert file1['sha256'] == 'b2915eb69f260d8d3c25249195f2c8f4f716ea82ec760ae929732c0262442b2b'
|
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):
|
def _get_sizes(self, compression, compressible, size=10000):
|
||||||
if compressible:
|
if compressible:
|
||||||
contents = b'X' * size
|
contents = b'X' * size
|
||||||
|
|
Loading…
Reference in New Issue