[Feature Request] Include Test::Minion subclass/role of Test::Mojo
kiwiroy opened this issue · comments
It would be nice to have a Test::Minion
module to use with apps that plugin Minion => {};
.
Something to simplify enqueuing, performing and testing of tasks. I started a branch master...kiwiroy:test-minion and was thinking something like
$t = Test::Minion->new;
$t->task_exists('add')
->task_exists('convert')
->task_is(add => [1, 1], 2, $desc)
->task_is(convert => ['image.jpg'], 'image.png', $desc)
->perform_jobs;
Interesting idea, perform_jobs
should probably be perform_jobs_ok
.
And i wouldn't mind shipping a role with Minion either.
my $t = Test::Mojo->new(...)->with_roles('+Minion');
But i do think this is currently blocked by Test::Mojo::_test
being a private API. We'll have to figure out a better alternative for that in Mojolicious first.
Yeah, I missed the perform_jobs_ok
- that's kinda obvious now. There's also missing increments of $Test::Builder::Level
. Shipping Test::Minion
means depending Role::Tiny
.
And task_is
looks more like it should be enqueue_ok
.
while you're at it, you probably want to be able to assert things against the result of the job. Sometimes you're testing that it fails, sometimes that it succeeded, etc.
Test::Mojo
has been updated to make this easier. mojolicious/mojo@4f1fb79...3723973#diff-ee9e1eca670f561769d858a66424416e
Good work on Test::Mojo
. I've updated the branch. Waiting on release before PR. master...kiwiroy:test-minion#diff-327a0d12729d8cb0b9a10520244a9b22R7
@rabbiveesh enqueue_ok
requires a result or subtest
block that will be tested by perform_jobs_ok
. The subtest can test any state of $job
not just $job->info->{result}
. Additionally, job_is
can do the same for any children (jobs enqueued by others).
@kiwiroy Please be aware that your branch will need a lot of cleaning up before it can be considered.
I'm starting to believe that this might not be such a good idea after all. This definitely should be prototyped as a module on CPAN (just leave the Test::Minion
namespace for core Minion use).