From f81e8495a7944eb9684580d99f40bbdb4b3f7f93 Mon Sep 17 00:00:00 2001 From: Michal Borychowski <807297+boryn@users.noreply.github.com> Date: Mon, 2 Oct 2023 22:48:44 +0200 Subject: [PATCH] test for adding timestamp to database dump file --- tests/Commands/BackupCommandTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Commands/BackupCommandTest.php b/tests/Commands/BackupCommandTest.php index 314c1b8b..e09a7ab1 100644 --- a/tests/Commands/BackupCommandTest.php +++ b/tests/Commands/BackupCommandTest.php @@ -310,6 +310,23 @@ app()['db']->disconnect(); }); +it('appends timestamp to database backup file name', function () { + config()->set('backup.backup.source.databases', ['db1']); + config()->set('backup.backup.database_dump_file_timestamp_format', 'Y-m-d-H-i-s'); + + $this->setUpDatabase(app()); + + $this->artisan('backup:run --only-db')->assertExitCode(0); + + $this->assertExactPathExistsInZip('local', $this->expectedZipPath, 'db-dumps/sqlite-db1-database-2016-01-01-21-01-01.sql'); + + /* + * Close the database connection to unlock the sqlite file for deletion. + * This prevents the errors from other tests trying to delete and recreate the folder. + */ + app()['db']->disconnect(); +}); + it('should trigger the backup failed event', function () { // use an invalid dbname to trigger failure $this->artisan('backup:run --only-db --db-name=wrongName')->assertExitCode(1);