Skip to content

Commit 2f2f4ee

Browse files
authored
Improvements for Contributors / Testing (#34)
* Remove extra test file * Rename soon to be deprecated assertions * Add newline * Keep the cache directory as it is expected for tests to pass * Style Updates * Style Updates
1 parent 07110a5 commit 2f2f4ee

5 files changed

+18
-19
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor/
22
/credentials/
33
composer.lock
4-
/tests/cache/
4+
/tests/cache/*
5+
!/tests/cache/.gitkeep

tests/ExampleTest.php

-12
This file was deleted.

tests/MakeSheetModelCommandTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ public function it_creates_a_sheet_model_without_committing_any_crimes()
3636
$this->assertFileExists('tests/cache/sushi-tests-models-my-sheet-model.sqlite');
3737

3838
$work->first()->invalidateCache();
39-
$this->assertFileNotExists('tests/cache/sushi-tests-models-my-sheet-model.sqlite');
39+
$this->assertFileDoesNotExist('tests/cache/sushi-tests-models-my-sheet-model.sqlite');
4040
}
4141
}

tests/SheetModelTest.php

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Tests;
44

5-
use Illuminate\Support\Facades\File;
65
use Tests\Models\DefineHeadersModel;
76
use Tests\Models\InferredIdModel;
87
use Tests\Models\TestModel;
@@ -24,11 +23,22 @@ public function setUp(): void
2423
config(['sushi.cache-path' => $this->cachePath = __DIR__.'/cache']);
2524
}
2625

26+
public function tearDown(): void
27+
{
28+
$this->clearCacheDirectory();
29+
parent::tearDown();
30+
}
31+
32+
private function clearCacheDirectory()
33+
{
34+
array_map('unlink', glob(config('sushi.cache-path').'/*'));
35+
}
36+
2737
/** @test */
2838
public function can_read_from_google_sheets()
2939
{
30-
File::cleanDirectory(config('sushi.cache-path'));
31-
$this->assertFileNotExists('tests/cache/sushi-tests-models-test-model.sqlite');
40+
$this->clearCacheDirectory();
41+
$this->assertFileDoesNotExist('tests/cache/sushi-tests-models-test-model.sqlite');
3242
$sheet = new TestModel();
3343
$this->assertIsArray($sheet->getRows());
3444
}
@@ -78,7 +88,7 @@ public function can_invalidate_cache()
7888
$sheet = TestModel::find(1);
7989
$this->assertFileExists('tests/cache/sushi-tests-models-test-model.sqlite');
8090
$sheet->invalidateCache();
81-
$this->assertFileNotExists('tests/cache/sushi-tests-models-test-model.sqlite');
91+
$this->assertFileDoesNotExist('tests/cache/sushi-tests-models-test-model.sqlite');
8292
$sheet = TestModel::find(2);
8393
$this->assertEquals('Justine', $sheet->name);
8494
}
@@ -90,6 +100,6 @@ public function can_invalidate_cache_by_request()
90100
$this->assertFileExists('tests/cache/sushi-tests-models-test-model.sqlite');
91101
$response = $this->get('/eloquent_sheets_forget/'.$sheet->cacheName);
92102
$response->assertSuccessful();
93-
$this->assertFileNotExists('tests/cache/sushi-tests-test-model.sqlite');
103+
$this->assertFileDoesNotExist('tests/cache/sushi-tests-test-model.sqlite');
94104
}
95105
}

tests/cache/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)