From 088da190129786a0a092be11086ee43326ff4601 Mon Sep 17 00:00:00 2001 From: Gautam Aggarwal Date: Thu, 27 Mar 2025 11:26:56 +0000 Subject: [PATCH] Added Unit Tests --- borgmatic/config/schema.yaml | 8 ++++++-- tests/unit/commands/test_borgmatic.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/borgmatic/config/schema.yaml b/borgmatic/config/schema.yaml index 65ba9f773..7a4c4a28f 100644 --- a/borgmatic/config/schema.yaml +++ b/borgmatic/config/schema.yaml @@ -2670,6 +2670,10 @@ properties: description: | Whether to apply default actions (e.g., backup) when no arguments are supplied to the borgmatic command. If set to true, borgmatic - will trigger the default actions. If set to false, borgmatic will - display the help message instead. + will trigger the default actions,which include : + -Create backups based on your configured schedules and paths. + - Prune old backups based on your retention policies. + - Verify the integrity of your backups. + + If set to false, borgmatic will display the help message instead. example: true diff --git a/tests/unit/commands/test_borgmatic.py b/tests/unit/commands/test_borgmatic.py index 160f44543..15512a678 100644 --- a/tests/unit/commands/test_borgmatic.py +++ b/tests/unit/commands/test_borgmatic.py @@ -2079,3 +2079,23 @@ def test_collect_configuration_run_summary_logs_outputs_merged_json_results(): arguments=arguments, ) ) +def test_check_and_show_help_on_no_args_shows_help_when_no_args_and_default_actions_false(): + flexmock(module.sys).should_receive('argv').and_return(['borgmatic']) + flexmock(module).should_receive('parse_arguments').with_args('--help').once() + flexmock(module.sys).should_receive('exit').with_args(0).once() + module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}}) + + +def test_check_and_show_help_on_no_args_does_not_show_help_when_no_args_and_default_actions_true(): + flexmock(module.sys).should_receive('argv').and_return(['borgmatic']) + flexmock(module).should_receive('parse_arguments').never() + flexmock(module.sys).should_receive('exit').never() + module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': True}}) + + +def test_check_and_show_help_on_no_args_does_not_show_help_when_args_provided(): + flexmock(module.sys).should_receive('argv').and_return(['borgmatic', '--create']) + flexmock(module).should_receive('parse_arguments').never() + flexmock(module.sys).should_receive('exit').never() + module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}}) +