mirror of https://github.com/borgbackup/borg.git
rdelete_cmd converted
This commit is contained in:
parent
216f13831e
commit
a3bfc4d390
|
@ -1,30 +1,25 @@
|
||||||
import os
|
import os
|
||||||
import unittest
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from ...constants import * # NOQA
|
from ...constants import * # NOQA
|
||||||
from . import ArchiverTestCaseBase, RemoteArchiverTestCaseBase, ArchiverTestCaseBinaryBase, RK_ENCRYPTION, BORG_EXES
|
from . import create_regular_file, cmd, RK_ENCRYPTION
|
||||||
|
|
||||||
|
|
||||||
class ArchiverTestCase(ArchiverTestCaseBase):
|
@pytest.mark.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
|
||||||
def test_delete_repo(self):
|
def test_delete_repo(archivers, request):
|
||||||
self.create_regular_file("file1", size=1024 * 80)
|
archiver = request.getfixturevalue(archivers)
|
||||||
self.create_regular_file("dir2/file2", size=1024 * 80)
|
repo_location, repo_path, input_path = archiver.repository_location, archiver.repository_path, archiver.input_path
|
||||||
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
|
create_regular_file(input_path, "file1", size=1024 * 80)
|
||||||
self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
|
create_regular_file(input_path, "dir2/file2", size=1024 * 80)
|
||||||
self.cmd(f"--repo={self.repository_location}", "create", "test.2", "input")
|
|
||||||
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "no"
|
|
||||||
self.cmd(f"--repo={self.repository_location}", "rdelete", exit_code=2)
|
|
||||||
assert os.path.exists(self.repository_path)
|
|
||||||
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "YES"
|
|
||||||
self.cmd(f"--repo={self.repository_location}", "rdelete")
|
|
||||||
# Make sure the repo is gone
|
|
||||||
self.assertFalse(os.path.exists(self.repository_path))
|
|
||||||
|
|
||||||
|
cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
|
||||||
class RemoteArchiverTestCase(RemoteArchiverTestCaseBase, ArchiverTestCase):
|
cmd(archiver, f"--repo={repo_location}", "create", "test", "input")
|
||||||
"""run the same tests, but with a remote repository"""
|
cmd(archiver, f"--repo={repo_location}", "create", "test.2", "input")
|
||||||
|
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "no"
|
||||||
|
cmd(archiver, f"--repo={repo_location}", "rdelete", exit_code=2)
|
||||||
@unittest.skipUnless("binary" in BORG_EXES, "no borg.exe available")
|
assert os.path.exists(repo_path)
|
||||||
class ArchiverTestCaseBinary(ArchiverTestCaseBinaryBase, ArchiverTestCase):
|
os.environ["BORG_DELETE_I_KNOW_WHAT_I_AM_DOING"] = "YES"
|
||||||
"""runs the same tests, but via the borg binary"""
|
cmd(archiver, f"--repo={repo_location}", "rdelete")
|
||||||
|
# Make sure the repo is gone
|
||||||
|
assert not os.path.exists(repo_path)
|
||||||
|
|
Loading…
Reference in New Issue