Document validate-borgmatic-config and add a few tests.
All checks were successful
the build was successful
All checks were successful
the build was successful
This commit is contained in:
parent
6a10022543
commit
8650a15db1
7 changed files with 80 additions and 40 deletions
36
tests/end-to-end/test_validate_config.py
Normal file
36
tests/end-to-end/test_validate_config.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def test_validate_config_command_with_valid_configuration_succeeds():
|
||||
with tempfile.TemporaryDirectory() as temporary_directory:
|
||||
config_path = os.path.join(temporary_directory, 'test.yaml')
|
||||
|
||||
subprocess.check_call(
|
||||
'generate-borgmatic-config --destination {}'.format(config_path).split(' ')
|
||||
)
|
||||
exit_code = subprocess.call(
|
||||
'validate-borgmatic-config --config {}'.format(config_path).split(' ')
|
||||
)
|
||||
|
||||
assert exit_code == 0
|
||||
|
||||
|
||||
def test_validate_config_command_with_invalid_configuration_fails():
|
||||
with tempfile.TemporaryDirectory() as temporary_directory:
|
||||
config_path = os.path.join(temporary_directory, 'test.yaml')
|
||||
|
||||
subprocess.check_call(
|
||||
'generate-borgmatic-config --destination {}'.format(config_path).split(' ')
|
||||
)
|
||||
config = open(config_path).read().replace('keep_daily: 7', 'keep_daily: "7"')
|
||||
config_file = open(config_path, 'w')
|
||||
config_file.write(config)
|
||||
config_file.close()
|
||||
|
||||
exit_code = subprocess.call(
|
||||
'validate-borgmatic-config --config {}'.format(config_path).split(' ')
|
||||
)
|
||||
|
||||
assert exit_code == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue