mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-12 02:02:15 +01:00
Fixed import lock
This commit is contained in:
committed by
Constantin Graf
parent
29929467f6
commit
62270382dc
@@ -35,6 +35,8 @@ class ImportServiceTest extends TestCase
|
||||
$report = $importService->import($organization, 'toggl_time_entries', $data, $timezone);
|
||||
|
||||
// Assert
|
||||
$lock = Cache::lock('import:'.$organization->getKey());
|
||||
$this->assertTrue($lock->get());
|
||||
$this->assertSame(2, $report->timeEntriesCreated);
|
||||
$this->assertSame(2, $report->tagsCreated);
|
||||
$this->assertSame(1, $report->tasksCreated);
|
||||
@@ -43,6 +45,25 @@ class ImportServiceTest extends TestCase
|
||||
$this->assertSame(1, $report->clientsCreated);
|
||||
}
|
||||
|
||||
public function test_import_releases_lock_if_an_exception_happens_during_the_import(): void
|
||||
{
|
||||
// Arrange
|
||||
Storage::fake(config('filesystems.default'));
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$data = 'Invalid CSV data';
|
||||
|
||||
// Act
|
||||
$importService = app(ImportService::class);
|
||||
try {
|
||||
$importService->import($organization, 'toggl_time_entries', $data, $timezone);
|
||||
} catch (ImportException) {
|
||||
// Assert
|
||||
$lock = Cache::lock('import:'.$organization->getKey());
|
||||
$this->assertTrue($lock->get());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_import_throws_exception_if_import_is_already_in_progress(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in New Issue
Block a user