mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
refactor test_return_codes
... so works in a similar way as test_exit_codes.
This commit is contained in:
parent
0b284db33a
commit
8ec48ffb05
1 changed files with 16 additions and 16 deletions
|
|
@ -3,28 +3,28 @@ import os
|
|||
from ...constants import * # NOQA
|
||||
from ...helpers import IncludePatternNeverMatchedWarning
|
||||
from ...repository import Repository
|
||||
from . import cmd, cmd_fixture, changedir, generate_archiver_tests # NOQA
|
||||
from . import cmd, changedir, generate_archiver_tests # NOQA
|
||||
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_return_codes(cmd_fixture, tmpdir):
|
||||
repo = tmpdir / "repo" # borg creates the directory
|
||||
input = tmpdir.mkdir("input")
|
||||
output = tmpdir.mkdir("output")
|
||||
input.join("test_file").write("content")
|
||||
rc, out = cmd_fixture("--repo=%s" % str(repo), "repo-create", "--encryption=none")
|
||||
assert rc == EXIT_SUCCESS
|
||||
rc, out = cmd_fixture("--repo=%s" % repo, "create", "archive", str(input))
|
||||
assert rc == EXIT_SUCCESS
|
||||
with changedir(str(output)):
|
||||
rc, out = cmd_fixture("--repo=%s" % repo, "extract", "archive")
|
||||
assert rc == EXIT_SUCCESS
|
||||
rc, out = cmd_fixture("--repo=%s" % repo, "extract", "archive", "does/not/match")
|
||||
assert rc == IncludePatternNeverMatchedWarning().exit_code
|
||||
def test_return_codes(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
cmd(archiver, "repo-create", "--encryption=none")
|
||||
cmd(archiver, "create", "archive", "input")
|
||||
with changedir("output"):
|
||||
cmd(archiver, "extract", "archive")
|
||||
cmd(
|
||||
archiver,
|
||||
"extract",
|
||||
"archive",
|
||||
"does/not/match",
|
||||
fork=True,
|
||||
exit_code=IncludePatternNeverMatchedWarning().exit_code,
|
||||
)
|
||||
|
||||
|
||||
def test_exit_codes(archivers, request, tmpdir, monkeypatch):
|
||||
def test_exit_codes(archivers, request, monkeypatch):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
# we create the repo path, but do NOT initialize the borg repo,
|
||||
# so the borg create commands are expected to fail with DoesNotExist (was: InvalidRepository in borg 1.4).
|
||||
|
|
|
|||
Loading…
Reference in a new issue