-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stats endpoint error when fetching failed job count (#4)
* remove trycatch * create test to suit expected outcome * Apply fixes from StyleCI * remove result cache * enable tests * eod checkin * Apply fixes from StyleCI * test passing locally * Apply fixes from StyleCI * php stan * test queue is marked as running * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
74e197f
commit 61bf2a7
Showing
14 changed files
with
258 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ jobs: | |
run: | ||
uses: flarum/framework/.github/workflows/[email protected] | ||
with: | ||
enable_backend_testing: false | ||
enable_backend_testing: true | ||
enable_phpstan: true | ||
|
||
backend_directory: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
js/node_modules | ||
vendor/ | ||
composer.lock | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of blomstra/database-queue | ||
* | ||
* Copyright (c) 2023 Blomstra Ltd. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
* | ||
*/ | ||
|
||
namespace Blomstra\DatabaseQueue\Provider; | ||
|
||
use Illuminate\Database\ConnectionInterface; | ||
use Illuminate\Database\ConnectionResolverInterface; | ||
|
||
class DatabaseUuidFailedJobProvider extends \Illuminate\Queue\Failed\DatabaseUuidFailedJobProvider | ||
{ | ||
protected $connection; | ||
|
||
public function __construct(ConnectionResolverInterface $resolver, $database, $table, ConnectionInterface $connection) | ||
{ | ||
parent::__construct($resolver, $database, $table); | ||
|
||
$this->connection = $connection; | ||
} | ||
|
||
/** | ||
* Get a new query builder instance for the table. | ||
* | ||
* @return \Illuminate\Database\Query\Builder | ||
*/ | ||
protected function getTable() | ||
{ | ||
return $this->connection->table($this->table); | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of blomstra/database-queue | ||
* | ||
* Copyright (c) 2023 Blomstra Ltd. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
* | ||
*/ | ||
|
||
namespace Blomstra\DatabaseQueue\Tests\integration\api; | ||
|
||
use Flarum\Testing\integration\ConsoleTestCase; | ||
|
||
class StatsTest extends ConsoleTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
$this->extension('blomstra-database-queue'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function non_admin_cannot_access_stats() | ||
{ | ||
$response = $this->send($this->request( | ||
'GET', | ||
'/api/database-queue/stats' | ||
)); | ||
|
||
$this->assertEquals(404, $response->getStatusCode()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function admin_can_access_stats() | ||
{ | ||
$response = $this->send($this->request( | ||
'GET', | ||
'/api/database-queue/stats', | ||
[ | ||
'authenticatedAs' => 1, | ||
] | ||
)); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$body = json_decode($response->getBody(), true); | ||
|
||
$this->assertEquals('default', $body['queue']); | ||
$this->assertEquals('inactive', $body['status']); | ||
$this->assertEquals(0, $body['pendingJobs']); | ||
$this->assertEquals(0, $body['failedJobs']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function admin_can_access_stats_with_queue() | ||
{ | ||
$commandOutput = $this->runCommand(['command' => 'queue:work', '--stop-when-empty' => true]); | ||
|
||
$this->assertEmpty($commandOutput); | ||
|
||
$response = $this->send($this->request( | ||
'GET', | ||
'/api/database-queue/stats', | ||
[ | ||
'authenticatedAs' => 1, | ||
] | ||
)); | ||
|
||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$body = json_decode($response->getBody(), true); | ||
|
||
$this->assertEquals('default', $body['queue']); | ||
$this->assertEquals('running', $body['status']); | ||
$this->assertEquals(0, $body['pendingJobs']); | ||
$this->assertEquals(0, $body['failedJobs']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of blomstra/database-queue | ||
* | ||
* Copyright (c) 2023 Blomstra Ltd. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
* | ||
*/ | ||
|
||
use Flarum\Testing\integration\Setup\SetupScript; | ||
|
||
require __DIR__.'/../../vendor/autoload.php'; | ||
|
||
$setup = new SetupScript(); | ||
|
||
$setup->run(); |
Oops, something went wrong.