Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Include Test::Minion subclass/role of Test::Mojo #95

Open
kiwiroy opened this issue Mar 31, 2020 · 10 comments
Open

[Feature Request] Include Test::Minion subclass/role of Test::Mojo #95

kiwiroy opened this issue Mar 31, 2020 · 10 comments

Comments

@kiwiroy
Copy link
Contributor

kiwiroy commented Mar 31, 2020

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;
@kraih
Copy link
Member

kraih commented Mar 31, 2020

Interesting idea, perform_jobs should probably be perform_jobs_ok.

@kraih
Copy link
Member

kraih commented Mar 31, 2020

And i wouldn't mind shipping a role with Minion either.

my $t = Test::Mojo->new(...)->with_roles('+Minion');

@kraih
Copy link
Member

kraih commented Mar 31, 2020

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.

@kiwiroy
Copy link
Contributor Author

kiwiroy commented Mar 31, 2020

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.

@kraih
Copy link
Member

kraih commented Mar 31, 2020

And task_is looks more like it should be enqueue_ok.

@rabbiveesh
Copy link

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.

@kraih
Copy link
Member

kraih commented Mar 31, 2020

Test::Mojo has been updated to make this easier. mojolicious/mojo@4f1fb79...3723973#diff-ee9e1eca670f561769d858a66424416e

@kiwiroy
Copy link
Contributor Author

kiwiroy commented Apr 2, 2020

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).

@kraih
Copy link
Member

kraih commented Apr 2, 2020

@kiwiroy Please be aware that your branch will need a lot of cleaning up before it can be considered.

@kraih
Copy link
Member

kraih commented Feb 15, 2021

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants