Skip to content

Commit

Permalink
test_sanity_checks test cases added
Browse files Browse the repository at this point in the history
  • Loading branch information
per2jensen committed Jan 3, 2025
1 parent 80da8d0 commit c1bdcac
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions v2/tests/test_sanity_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# modified: 2021-07-25 to be a pytest test
import importlib
import re
import sys
import os

from tests.envdata import EnvData


from dar_backup.util import run_command

def create_test_files(env: EnvData) -> dict:
env.logger.info("Creating test dummy archive files...")
test_files = {
f'dummy_FULL_.1.dar': 'dummy',
}
for filename, content in test_files.items():
with open(os.path.join(env.test_dir, 'backups', filename), 'w') as f:
f.write(content)

return test_files

def test_dar_backup_definition_with_underscore(setup_environment, env):
command = ['dar-backup', '--full-backup', '--config-file', env.config_file, '-d', 'example_2']
process = run_command(command)
if process.returncode == 0:
raise Exception(f'dar-backup must fail on a backup definition with an underscore in the name')

def test_dar_backup_nonexistent_definition_(setup_environment, env):
command = ['dar-backup', '--full-backup', '--config-file', env.config_file, '-d', 'nonexistent_definition']
process = run_command(command)
if process.returncode == 0:
raise Exception(f'dar-backup must fail if backup definition is not found')

0 comments on commit c1bdcac

Please sign in to comment.