1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-20 21:27:32 +00:00

added unittest for get_config_dir function

This commit is contained in:
Narendra Vardi 2017-10-25 23:07:45 +05:30
parent 56fed4f964
commit a3f1e6e250

View file

@ -18,7 +18,7 @@
from ..helpers import partial_format, format_file_size, parse_file_size, format_timedelta, format_line, PlaceholderError, replace_placeholders
from ..helpers import make_path_safe, clean_lines
from ..helpers import interval, prune_within, prune_split
from ..helpers import get_cache_dir, get_keys_dir, get_security_dir
from ..helpers import get_cache_dir, get_keys_dir, get_security_dir, get_config_dir
from ..helpers import is_slow_msgpack
from ..helpers import yes, TRUISH, FALSISH, DEFAULTISH
from ..helpers import StableDict, int_to_bigint, bigint_to_int, bin_to_hex
@ -447,6 +447,17 @@ def test(self):
self.assert_equal(parse_timestamp('2015-04-19T20:25:00'), datetime(2015, 4, 19, 20, 25, 0, 0, timezone.utc))
def test_get_config_dir(monkeypatch):
"""test that get_config_dir respects environment"""
monkeypatch.delenv('BORG_CONFIG_DIR', raising=False)
monkeypatch.delenv('XDG_CONFIG_HOME', raising=False)
assert get_config_dir() == os.path.join(os.path.expanduser('~'), '.config', 'borg')
monkeypatch.setenv('XDG_CONFIG_HOME', '/var/tmp/.config')
assert get_config_dir() == os.path.join('/var/tmp/.config', 'borg')
monkeypatch.setenv('BORG_CONFIG_DIR', '/var/tmp')
assert get_config_dir() == '/var/tmp'
def test_get_cache_dir(monkeypatch):
"""test that get_cache_dir respects environment"""
monkeypatch.delenv('BORG_CACHE_DIR', raising=False)