-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make the time for temporarily failed jobs configurable (#1375)
- Loading branch information
1 parent
5de2d42
commit 37defc6
Showing
2 changed files
with
50 additions
and
1 deletion.
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
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,49 @@ | ||
<?php | ||
|
||
namespace Laravel\Horizon\Tests\Feature\Listeners; | ||
|
||
use Exception; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
use Illuminate\Queue\Jobs\Job; | ||
use Laravel\Horizon\Contracts\TagRepository; | ||
use Laravel\Horizon\Events\JobFailed; | ||
use Laravel\Horizon\Tests\IntegrationTest; | ||
use Mockery as m; | ||
|
||
class StoreTagsForFailedTest extends IntegrationTest | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
m::close(); | ||
} | ||
|
||
public function test_temporary_failed_job_should_be_deleted_when_the_main_job_is_deleted(): void | ||
{ | ||
config()->set('horizon.trim.failed', 120); | ||
|
||
$tagRepository = m::mock(TagRepository::class); | ||
|
||
$tagRepository->shouldReceive('addTemporary')->once()->with(120, '1', ['failed:foobar'])->andReturn([]); | ||
|
||
$this->instance(TagRepository::class, $tagRepository); | ||
|
||
$this->app->make(Dispatcher::class)->dispatch(new JobFailed( | ||
new Exception('job failed'), new FailedJob(), '{"id":"1","displayName":"displayName","tags":["foobar"]}' | ||
)); | ||
} | ||
} | ||
|
||
class FailedJob extends Job | ||
{ | ||
public function getJobId() | ||
{ | ||
return '1'; | ||
} | ||
|
||
public function getRawBody() | ||
{ | ||
return ''; | ||
} | ||
} |