Deprecate validate-borgmatic-config in favor of new "config validate" action (#529).
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
0
tests/integration/actions/__init__.py
Normal file
0
tests/integration/actions/__init__.py
Normal file
0
tests/integration/actions/config/__init__.py
Normal file
0
tests/integration/actions/config/__init__.py
Normal file
37
tests/integration/actions/config/test_validate.py
Normal file
37
tests/integration/actions/config/test_validate.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import argparse
|
||||
|
||||
from flexmock import flexmock
|
||||
|
||||
import borgmatic.logger
|
||||
from borgmatic.actions.config import validate as module
|
||||
|
||||
|
||||
def test_run_validate_with_show_renders_configurations():
|
||||
log_lines = []
|
||||
borgmatic.logger.add_custom_log_levels()
|
||||
|
||||
def fake_logger_answer(message):
|
||||
log_lines.append(message)
|
||||
|
||||
flexmock(module.logger).should_receive('answer').replace_with(fake_logger_answer)
|
||||
|
||||
module.run_validate(argparse.Namespace(show=True), {'test.yaml': {'foo': {'bar': 'baz'}}})
|
||||
|
||||
assert log_lines == ['''foo:\n bar: baz\n''']
|
||||
|
||||
|
||||
def test_run_validate_with_show_and_multiple_configs_renders_each():
|
||||
log_lines = []
|
||||
borgmatic.logger.add_custom_log_levels()
|
||||
|
||||
def fake_logger_answer(message):
|
||||
log_lines.append(message)
|
||||
|
||||
flexmock(module.logger).should_receive('answer').replace_with(fake_logger_answer)
|
||||
|
||||
module.run_validate(
|
||||
argparse.Namespace(show=True),
|
||||
{'test.yaml': {'foo': {'bar': 'baz'}}, 'other.yaml': {'quux': 'value'}},
|
||||
)
|
||||
|
||||
assert log_lines == ['---', 'foo:\n bar: baz\n', '---', 'quux: value\n']
|
||||
@@ -3,27 +3,7 @@ from flexmock import flexmock
|
||||
from borgmatic.commands import validate_config as module
|
||||
|
||||
|
||||
def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||
config_paths = ['default']
|
||||
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
||||
def test_main_does_not_raise():
|
||||
flexmock(module.borgmatic.commands.borgmatic).should_receive('main')
|
||||
|
||||
parser = module.parse_arguments()
|
||||
|
||||
assert parser.config_paths == config_paths
|
||||
|
||||
|
||||
def test_parse_arguments_with_multiple_config_paths_parses_as_list():
|
||||
flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
|
||||
|
||||
parser = module.parse_arguments('--config', 'myconfig', 'otherconfig')
|
||||
|
||||
assert parser.config_paths == ['myconfig', 'otherconfig']
|
||||
|
||||
|
||||
def test_parse_arguments_supports_show_flag():
|
||||
config_paths = ['default']
|
||||
flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
|
||||
|
||||
parser = module.parse_arguments('--config', 'myconfig', '--show')
|
||||
|
||||
assert parser.show
|
||||
module.main()
|
||||
|
||||
Reference in New Issue
Block a user