Files
borgmatic/tests/integration/borg/test_rename.py
Tobias SchlatterandDan Helfman 123f8958f6 Create a checkpoint archive first with streaming processes (#1032).
This ensures that if a streaming process fails, we do not create a
real (i.e. non-checkpoint archive), (fixes #1032).

Without this, there is a race condition where borg already creates an
archive before borgmatic can kill it.

Tested locally (with `pipx install --editable .`):

```sh
borgmatic --config config.yaml create
borgmatic --config config.yaml create --json
```

## Hold up!

Thanks for your contribution. Unfortunately, we don't use GitHub pull requests to manage code contributions to this repository (and GitHub doesn't have any way to disable pull requests entirely). Instead, please see:

https://torsion.org/borgmatic/#contributing

... which provides full instructions on how to submit pull requests. You can even use your GitHub account to login.

Reviewed-on: https://projects.torsion.org/borgmatic-collective/borgmatic/pulls/1102
Reviewed-by: Dan Helfman <witten@torsion.org>
Co-authored-by: Tobias Schlatter <schlatter.tobias@gmail.com>
Co-committed-by: Tobias Schlatter <schlatter.tobias@gmail.com>
2025-06-25 16:24:07 +00:00

121 lines
3.3 KiB
Python

import logging
from borgmatic.borg import rename as module
from tests.unit.test_verbosity import insert_logging_mock
def test_make_rename_command_includes_log_info():
insert_logging_mock(logging.INFO)
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--info', 'repo::old_archive', 'new_archive')
def test_make_rename_command_includes_log_debug():
insert_logging_mock(logging.DEBUG)
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--debug', '--show-rc', 'repo::old_archive', 'new_archive')
def test_make_rename_command_includes_dry_run():
command = module.make_rename_command(
dry_run=True,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--dry-run', 'repo::old_archive', 'new_archive')
def test_make_rename_command_includes_remote_path():
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={},
local_borg_version='1.2.3',
local_path='borg',
remote_path='borg1',
)
assert command == (
'borg',
'rename',
'--remote-path',
'borg1',
'repo::old_archive',
'new_archive',
)
def test_make_rename_command_includes_umask():
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={'umask': '077'},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--umask', '077', 'repo::old_archive', 'new_archive')
def test_make_rename_command_includes_log_json():
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={'log_json': True},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--log-json', 'repo::old_archive', 'new_archive')
def test_make_rename_command_includes_lock_wait():
command = module.make_rename_command(
dry_run=False,
repository_name='repo',
old_archive_name='old_archive',
new_archive_name='new_archive',
config={'lock_wait': 5},
local_borg_version='1.2.3',
local_path='borg',
remote_path=None,
)
assert command == ('borg', 'rename', '--lock-wait', '5', 'repo::old_archive', 'new_archive')