Test::Worker::Client - Mock Worker Client Class for Tests
use Test::Worker::Client;
Test::Worker::Client->set_test_root_directory;
{
Test::Worker::Client->new->insert(
'Job::Class',
{
arg1 => 'value1',
arg2 => 'value2',
},
);
}
my $job = Test::Worker::Client->new->get_next_job;
is_deeply $job->as_testable_hash, {
class => 'Job::Class',
arg => {
arg1 => 'value1',
arg2 => 'value2',
},
run_after => undef,
};
$job->completed;
- Test::Worker::Client->set_test_root_directory
-
Set worker job directory. Inserted worker jobs are stored as files in this directory.
- $client = Test::Worker::Client->new
-
Return an instance of the worker client.
- $job = $client->get_next_job
-
Return a Test::Worker::Client::Job object if there are non-completed jobs.
- $client->execute_job($job)
-
Execute the given job.
- $client->get_job_after_complete_jobs_unless($regexp)
-
Repeat
$client->get_next_job->completed
until the$job->class
matches$regexp
(or$client->get_next_job
returnsundef
) and then return the next job (which matches$regexp
), if any, orundef
. - $client->insert(...)
-
Insert a job. This method provides API compatible with the real worker client class.
Test::Worker::Client::Job, WorkerManager::Client::TheSchwartz.
Latest version of this module is available from <https://github.com/wakaba/perl-test-worker-client>.
If you prefer tarball, it is available at <http://wakaba.github.com/packages/perl/#Test-Worker-Client>. However, the tarball might be outdated.
- 1.0 (2012-03-21)
-
First packaged version.
Wakaba (id:wakabatan) <wakabatan@hatena.ne.jp>.
This module was initially developed as part of Ugomemo Hatena project, then renewed as part of Hatena Message 2010 project. Following people contributed to the module: mechairoi, motemen, hakobe, shibayu36, nanto_vi, suzak, and hitode909.
Copyright 2009-2012 Hatena <http://www.hatena.ne.jp/>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.