Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 913cbc75d3
Fetching contributors…

Cannot retrieve contributors at this time

file 44 lines (30 sloc) 0.884 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#!/usr/bin/env perl

use warnings;
use strict;

use Test::More;

use lib 'lib';
use lib '/root/contrib/reflex/lib';

{
package MyJob;
use Moose;
extends 'Reflex::Base';
with 'Reflex::Role::Collectible';
with 'Reflexive::WorkerPool::Role::Job';

sub work {}
}

use_ok 'Reflexive::WorkerPool';
use_ok 'Reflexive::WorkerPool::Worker';

my $worker_pool = Reflexive::WorkerPool->new();
isa_ok $worker_pool, 'Reflexive::WorkerPool', 'WorkerPool Instantiated';

my $job = MyJob->new();
$worker_pool->enqueue_job($job);

my ( $job_started, $job_stopped ) = ( 0, 0 );

while (my $event = $worker_pool->next()) {
$job_started = 1 if $event->{name} eq 'job_started';
$job_stopped = 1 if $event->{name} eq 'job_stopped';

last if ($event->{name} eq 'job_stopped');
}

ok $job_started, 'got job_started event';
ok $job_stopped, 'got_job stopped event';

pass 'All done!';

done_testing();
Something went wrong with that request. Please try again.