Skip to content

Commit

Permalink
Fixes for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Jan 14, 2024
1 parent 2e676e7 commit e424517
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Schema/CockroachSchemaState.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function dump(Connection $connection, $path): void
public function load($path): void
{
$fileContents = $this->files->get($path);
if (Str::squish($fileContents) === '') {
if ($fileContents === '') {
throw new \RuntimeException(sprintf('file %s is empty', $path));

Check warning on line 54 in src/Schema/CockroachSchemaState.php

View check run for this annotation

Codecov / codecov/patch

src/Schema/CockroachSchemaState.php#L54

Added line #L54 was not covered by tests
}

Expand Down
16 changes: 12 additions & 4 deletions tests/Integration/Database/DumpAndLoadSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ protected function setUp(): void

public function test_exporting_an_sql_dump()
{
File::ensureDirectoryExists(database_path('schema-test'));

if ($this->app['config']->get('database.default') !== 'testing') {
$this->artisan('db:wipe', ['--drop-views' => true]);
}
Expand All @@ -25,22 +27,25 @@ public function test_exporting_an_sql_dump()
$this->artisan('migrate', $options);

$this->beforeApplicationDestroyed(function () use ($options) {
File::delete(database_path('schema/crdb-schema.sql'));
File::delete(database_path('schema-test/crdb-schema.sql'));

$this->artisan('migrate:rollback', $options);
});

$this->artisan('schema:dump', [
'--database' => 'crdb',
'--path' => database_path('schema-test/crdb-schema.sql'),
])
->assertSuccessful();

$this->assertFileExists(database_path('schema-test/crdb-schema.sql'));
}

public function test_importing_an_sql_dump()
{
// Make sure the schema direct exists first
File::ensureDirectoryExists(database_path('schema'));
File::copy(__DIR__ . '/stubs/schema-dump.sql', database_path('schema/crdb-schema.sql'));
File::ensureDirectoryExists(database_path('schema-test'));
File::copy(__DIR__ . '/stubs/schema-dump.sql', database_path('schema-test/crdb-schema.sql'));

if ($this->app['config']->get('database.default') !== 'testing') {
$this->artisan('db:wipe', ['--drop-views' => true]);
Expand All @@ -57,7 +62,10 @@ public function test_importing_an_sql_dump()
$this->artisan('migrate:rollback', $options);
});

$this->artisan('migrate', $options);
$this->artisan('migrate', [
...$options,
...['--schema-path' => database_path('schema-test/crdb-schema.sql')]
]);

$this->assertDatabaseCount('migrations', 2);

Expand Down

0 comments on commit e424517

Please sign in to comment.