mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 01:15:37 +08:00
Add source hash comparator & refactor download lock
This commit is contained in:
@@ -57,7 +57,7 @@ class DownloaderTest extends TestCase
|
||||
|
||||
public function testLockSource()
|
||||
{
|
||||
Downloader::lockSource('fake-file', ['source_type' => 'archive', 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']);
|
||||
Downloader::lockSource('fake-file', ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']);
|
||||
$this->assertFileExists(DOWNLOAD_PATH . '/.lock.json');
|
||||
$json = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true);
|
||||
$this->assertIsArray($json);
|
||||
@@ -66,7 +66,7 @@ class DownloaderTest extends TestCase
|
||||
$this->assertArrayHasKey('filename', $json['fake-file']);
|
||||
$this->assertArrayHasKey('move_path', $json['fake-file']);
|
||||
$this->assertArrayHasKey('lock_as', $json['fake-file']);
|
||||
$this->assertEquals('archive', $json['fake-file']['source_type']);
|
||||
$this->assertEquals(SPC_SOURCE_ARCHIVE, $json['fake-file']['source_type']);
|
||||
$this->assertEquals('fake-file-name', $json['fake-file']['filename']);
|
||||
$this->assertEquals('fake-path', $json['fake-file']['move_path']);
|
||||
$this->assertEquals('fake-lock-as', $json['fake-file']['lock_as']);
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
putenv('SPC_IGNORE_BAD_HASH=yes');
|
||||
|
||||
require_once __DIR__ . '/../src/globals/internal-env.php';
|
||||
require_once __DIR__ . '/mock/SPC_store.php';
|
||||
|
||||
Reference in New Issue
Block a user