mirror of
https://github.com/borgbackup/borg.git
synced 2026-07-08 01:31:04 -04:00
tests: add test for BORG_JSON_COMPACT env var
This commit is contained in:
parent
a1a786b545
commit
9a882e8691
1 changed files with 17 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import base64
|
||||
import json
|
||||
import os
|
||||
|
||||
import re
|
||||
|
|
@ -718,3 +719,19 @@ def test_valid_chunkerparams(chunker_params, expected_return):
|
|||
def test_invalid_chunkerparams(invalid_chunker_params):
|
||||
with pytest.raises(ArgumentTypeError):
|
||||
ChunkerParams(invalid_chunker_params)
|
||||
|
||||
|
||||
def test_json_dump_compact(monkeypatch):
|
||||
from ...helpers.parseformat import json_dump
|
||||
|
||||
obj = {"key": "value", "number": 42}
|
||||
|
||||
# Default: pretty-printed (multi-line)
|
||||
result = json_dump(obj)
|
||||
assert "\n" in result
|
||||
|
||||
# With BORG_JSON_COMPACT set: single-line
|
||||
monkeypatch.setenv("BORG_JSON_COMPACT", "1")
|
||||
result = json_dump(obj)
|
||||
assert "\n" not in result
|
||||
assert json.loads(result) == obj
|
||||
|
|
|
|||
Loading…
Reference in a new issue