mirror of
https://github.com/koel/koel
synced 2024-11-10 06:34:14 +00:00
Assert that version is cached
This commit is contained in:
parent
b91d478fdf
commit
c4beca787b
2 changed files with 8 additions and 1 deletions
|
@ -10,6 +10,8 @@ use Illuminate\Log\Logger;
|
|||
|
||||
class ApplicationInformationService
|
||||
{
|
||||
private const CACHE_KEY = 'latestKoelVersion';
|
||||
|
||||
private $client;
|
||||
private $cache;
|
||||
private $logger;
|
||||
|
@ -26,7 +28,7 @@ class ApplicationInformationService
|
|||
*/
|
||||
public function getLatestVersionNumber(): string
|
||||
{
|
||||
return $this->cache->remember('latestKoelVersion', 1 * 24 * 60, function (): string {
|
||||
return $this->cache->remember(self::CACHE_KEY, 1 * 24 * 60, function (): string {
|
||||
try {
|
||||
return json_decode(
|
||||
$this->client->get('https://api.github.com/repos/phanan/koel/tags')->getBody()
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Integration\Services;
|
||||
|
||||
use App\Services\ApplicationInformationService;
|
||||
use Exception;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
|
@ -13,6 +14,9 @@ use Tests\TestCase;
|
|||
|
||||
class ApplicationInformationServiceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetLatestVersionNumber(): void
|
||||
{
|
||||
$latestVersion = 'v1.1.2';
|
||||
|
@ -25,5 +29,6 @@ class ApplicationInformationServiceTest extends TestCase
|
|||
$service = new ApplicationInformationService($client, app(Cache::class), app(Logger::class));
|
||||
|
||||
self::assertEquals($latestVersion, $service->getLatestVersionNumber());
|
||||
self::assertSame($latestVersion, cache('latestKoelVersion'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue