Skip to content

Commit 0877981

Browse files
author
Holger Lösken
committed
Properly reset test folder on each test
1 parent c2d02f8 commit 0877981

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

tests/Models/UpdateExecutorTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,19 @@ public function it_can_run_successfully(): void
5151
$this->release->extract();
5252

5353
$updateExecutor = (new UpdateExecutor())->setBasePath($dir);
54-
$this->assertTrue($updateExecutor->run($this->release));
5554

55+
$this->assertTrue($updateExecutor->run($this->release));
56+
$this->assertTrue(File::exists($dir . '/.some-hidden-file'));
57+
$this->assertTrue(File::exists($dir . '/outer-file.txt'));
58+
$this->assertTrue(File::exists($dir . '/folder1'));
59+
$this->assertEmpty(File::allFiles($dir . '/folder1'));
60+
$this->assertTrue(File::exists($dir . '/folder2'));
61+
$this->assertTrue(File::exists($dir . '/folder2/samplefile-in-folder2.txt'));
62+
$this->assertEquals(1, count(File::allFiles($dir . '/folder2')));
63+
$this->assertFalse(File::exists($dir . '/node_modules'));
64+
$this->assertFalse(File::exists($dir . '/__MACOSX'));
65+
$this->assertFalse(File::exists($dir . '/release-1.2'));
66+
$this->assertFalse(File::exists($dir . '/release-1.2.zip'));
5667
}
5768

5869
/** @test */

tests/SourceRepositoryTypes/GithubRepositoryTypeTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
class GithubRepositoryTypeTest extends TestCase
1818
{
19+
protected function setUp(): void
20+
{
21+
parent::setUp();
22+
$this->resetDownloadDir();
23+
}
24+
1925
/** @test */
2026
public function it_can_instantiate(): void
2127
{
@@ -55,7 +61,7 @@ public function it_can_run_update(): void
5561

5662
/** @var Release $release */
5763
$release = resolve(Release::class);
58-
$release->setStoragePath('/tmp')
64+
$release->setStoragePath((string) config('self-update.repository_types.github.download_path'))
5965
->setVersion('1.0')
6066
->setRelease('release-1.0.zip')
6167
->updateStoragePath()

tests/SourceRepositoryTypes/HttpRepositoryTypeTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
class HttpRepositoryTypeTest extends TestCase
1212
{
13+
protected function setUp(): void
14+
{
15+
parent::setUp();
16+
$this->resetDownloadDir();
17+
}
18+
1319
/** @test */
1420
public function it_can_instantiate(): void
1521
{
@@ -23,7 +29,7 @@ public function it_can_run_update(): void
2329
$http = resolve(HttpRepositoryType::class);
2430

2531
$release = resolve(Release::class);
26-
$release->setStoragePath('/tmp')
32+
$release->setStoragePath((string) config('self-update.repository_types.http.download_path'))
2733
->setRelease('release-1.0.zip')
2834
->updateStoragePath()
2935
->setDownloadUrl('some-local-file')
@@ -161,7 +167,7 @@ public function it_cannot_get_new_version_available_and_fails_with_exception():
161167
{
162168
$this->expectException(InvalidArgumentException::class);
163169

164-
/** @var HttpRepositoryType $github */
170+
/** @var HttpRepositoryType $http */
165171
$http = resolve(HttpRepositoryType::class);
166172
$http->isNewVersionAvailable('');
167173
}

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function getEnvironmentSetUp($app)
5656
'type' => 'http',
5757
'repository_url' => 'https://github.com/invoiceninja/invoiceninja/releases',
5858
'pkg_filename_format' => env('SELF_UPDATER_PKG_FILENAME_FORMAT', 'v_VERSION_'),
59-
'download_path' => env('SELF_UPDATER_DOWNLOAD_PATH', '/tmp'),
59+
'download_path' => self::DOWNLOAD_PATH,
6060
'private_access_token' => '',
6161
],
6262
],

0 commit comments

Comments
 (0)