Minion-Backend-Pg91
view release on metacpan or search on metacpan
use Minion;
use Mojo::IOLoop;
use Sys::Hostname 'hostname';
use Time::HiRes qw(time usleep);
use Mojo::Util 'dumper';
# Isolate tests
require Mojo::Pg;
my $pg = Mojo::Pg->new($ENV{TEST_ONLINE});
$pg->db->query('drop schema if exists minion_test cascade');
$pg->db->query('create schema minion_test');
my $minion = Minion->new(Pg91 => $ENV{TEST_ONLINE});
$minion->backend->pg->search_path(['minion_test']);
# Nothing to repair
my $worker = $minion->repair->worker;
isa_ok $worker->minion->app, 'Mojolicious', 'has default application';
# Migrate up and down
is $minion->backend->pg->migrations->active, 15, 'active version is 15';
[$worker->id]),
'sent command';
$_->process_commands for $worker, $worker2;
is_deeply \@commands,
[$worker->id, [23], [1, [2], {3 => 'three'}], $worker2->id],
'right structure';
$_->unregister for $worker, $worker2;
ok !$minion->backend->broadcast('test_id', []), 'command not sent';
# Clean up once we are done
$pg->db->query('drop schema minion_test cascade');
done_testing();
t/pg_lite_app.t view on Meta::CPAN
use Mojolicious::Lite;
use Test::Mojo;
# Missing backend
eval { plugin Minion => {Something => 'fun'} };
like $@, qr/^Backend "Minion::Backend::Something" missing/, 'right error';
# Isolate tests
require Mojo::Pg;
my $pg = Mojo::Pg->new($ENV{TEST_ONLINE});
$pg->db->query('drop schema if exists minion_app_test cascade');
$pg->db->query('create schema minion_app_test');
plugin Minion => {Pg91 => $ENV{TEST_ONLINE}};
app->minion->backend->pg->search_path(['minion_app_test']);
app->minion->add_task(
add => sub {
my ($job, $first, $second) = @_;
Mojo::IOLoop->next_tick(
sub {
$job->finish($first + $second);
t/pg_lite_app.t view on Meta::CPAN
$t->get_ok('/add' => form => {first => 4, second => 5})->status_is(200);
my $second = $t->tx->res->text;
Mojo::IOLoop->delay(sub { $t->app->minion->perform_jobs({queues => ['test']}) })
->wait;
$t->get_ok('/result' => form => {id => $first})->status_is(200)
->content_is('5');
$t->get_ok('/result' => form => {id => $second})->status_is(200)
->content_is('9');
# Clean up once we are done
$pg->db->query('drop schema minion_app_test cascade');
done_testing();
( run in 1.038 second using v1.01-cache-2.11-cpan-49f99fa48dc )