chore: add in some tests for backup
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
parent
7f433b84af
commit
9bf818eb4a
1 changed files with 36 additions and 0 deletions
|
|
@ -547,6 +547,42 @@ class TestBackups(BaseTestCommands):
|
|||
self.assertIn("successfully completed", self.stdout)
|
||||
self.assertNotEqual(before_backup["database"], after_backup["database"])
|
||||
|
||||
@skipIf(
|
||||
not (frappe.conf.db_type == "mariadb"),
|
||||
"Only for MariaDB",
|
||||
)
|
||||
def test_backup_extract_restore(self):
|
||||
"""Restore a backup after extracting"""
|
||||
self.execute("bench --site {site} backup")
|
||||
self.assertEqual(self.returncode, 0)
|
||||
backup = fetch_latest_backups()
|
||||
self.execute(f"gunzip {backup['database']}")
|
||||
self.assertEqual(self.returncode, 0)
|
||||
backup_sql = backup["database"].replace(".gz", "")
|
||||
assert os.path.isfile(backup_sql)
|
||||
self.execute(
|
||||
"bench --site {site} restore {backup_sql}",
|
||||
{
|
||||
"backup_sql": backup_sql,
|
||||
},
|
||||
)
|
||||
self.assertEqual(self.returncode, 0)
|
||||
|
||||
@skipIf(
|
||||
not (frappe.conf.db_type == "mariadb"),
|
||||
"Only for MariaDB",
|
||||
)
|
||||
def test_old_backup_restore(self):
|
||||
"""Restore a backup after extracting"""
|
||||
self.execute("bench --site {site} backup --old-backup-metadata")
|
||||
self.assertEqual(self.returncode, 0)
|
||||
backup = fetch_latest_backups()
|
||||
self.execute(
|
||||
"bench --site {site} restore {database}",
|
||||
backup,
|
||||
)
|
||||
self.assertEqual(self.returncode, 0)
|
||||
|
||||
def test_backup_fails_with_exit_code(self):
|
||||
"""Provide incorrect options to check if exit code is 1"""
|
||||
odb = BackupGenerator(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue