mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-01-26 03:34:02 +00:00
Filters for JSON files, closes #8
This commit is contained in:
@@ -106,9 +106,12 @@ class Updater
|
||||
return Collection::wrap($directory . '/' . $model . '.json');
|
||||
}
|
||||
|
||||
return collect(File::files($directory))->map(function ($path) {
|
||||
return $path->getPathname();
|
||||
});
|
||||
return collect(File::files($directory))
|
||||
->filter(function($file) {
|
||||
return pathinfo($file, PATHINFO_EXTENSION) == 'json';
|
||||
})->map(function ($path) {
|
||||
return $path->getPathname();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,4 +131,13 @@ class UpdaterTest extends TestCase
|
||||
$updater = new UpdaterFake(__DIR__ . '/../test-data/ordered');
|
||||
$updater->run();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_ignores_non_json_files()
|
||||
{
|
||||
$updater = new UpdaterFake(__DIR__ . '/../test-data/not-json');
|
||||
$updater->run();
|
||||
|
||||
$this->assertDatabaseMissing('roles', ['slug' => 'update-student-records']);
|
||||
}
|
||||
}
|
||||
9
tests/test-data/not-json/roles.txt
Normal file
9
tests/test-data/not-json/roles.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"_slug": "update-student-records",
|
||||
"category": "testing",
|
||||
"supervisor": {
|
||||
"name": "CEO"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user