Skip to content

Commit

Permalink
test for adding timestamp to database dump file
Browse files Browse the repository at this point in the history
  • Loading branch information
boryn authored and freekmurze committed Oct 9, 2023
1 parent b4216fd commit f81e849
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/Commands/BackupCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f81e849

Please sign in to comment.