/perl-test-worker-client

Test::Worker::Client - Perl test modules for TheSchwartz worker

Primary LanguagePerl

NAME

Test::Worker::Client - Mock Worker Client Class for Tests

SYNOPSIS

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;

METHODS

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 returns undef) and then return the next job (which matches $regexp), if any, or undef.

$client->insert(...)

Insert a job. This method provides API compatible with the real worker client class.

SEE ALSO

Test::Worker::Client::Job, WorkerManager::Client::TheSchwartz.

DISTRIBUTION

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.

CHANGES

1.0 (2012-03-21)

First packaged version.

AUTHOR

Wakaba (id:wakabatan) <wakabatan@hatena.ne.jp>.

ACKNOWLEDGEMENTS

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.

LICENSE

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.