2019-05-11 23:05:16 +02:00
|
|
|
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')
|
|
|
|
|
2023-03-24 07:11:14 +01:00
|
|
|
subprocess.check_call(f'generate-borgmatic-config --destination {config_path}'.split(' '))
|
|
|
|
exit_code = subprocess.call(f'validate-borgmatic-config --config {config_path}'.split(' '))
|
2019-05-11 23:05:16 +02:00
|
|
|
|
|
|
|
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')
|
|
|
|
|
2023-03-24 07:11:14 +01:00
|
|
|
subprocess.check_call(f'generate-borgmatic-config --destination {config_path}'.split(' '))
|
2019-05-11 23:05:16 +02:00
|
|
|
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()
|
|
|
|
|
2023-03-24 07:11:14 +01:00
|
|
|
exit_code = subprocess.call(f'validate-borgmatic-config --config {config_path}'.split(' '))
|
2019-05-11 23:05:16 +02:00
|
|
|
|
|
|
|
assert exit_code == 1
|