AnyEvent-WebService-Tracks
view release on metacpan or search on metacpan
t/02-context.t view on Meta::CPAN
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use List::MoreUtils qw(all);
use Scalar::Util qw(looks_like_number);
use Storable qw(dclone);
use Test::AnyEvent::WebService::Tracks;
use Test::Exception;
use UNIVERSAL ();
my @orig_contexts = qw(One Two Three Four);
my @contexts = @orig_contexts;
plan tests => 47 * @contexts + 34;
my $tracks = get_tracks;
run_tests_in_loop {
my ( $cond ) = @_;
my $run;
$run = sub {
my $name = shift @contexts;
$tracks->create_context($name, sub {
my ( $ctx ) = @_;
ok($ctx);
isa_ok($ctx, 'AnyEvent::WebService::Tracks::Context');
is($ctx->name, $name);
ok(looks_like_number $ctx->id);
isa_ok($ctx->created_at, 'DateTime');
isa_ok($ctx->updated_at, 'DateTime');
ok(looks_like_number $ctx->position);
ok(! $ctx->is_hidden);
dies_ok {
$ctx->id(0);
};
lives_ok {
$ctx->name('New Name');
};
dies_ok {
$ctx->created_at(DateTime->now);
};
dies_ok {
$ctx->updated_at(DateTime->now);
};
lives_ok {
$ctx->position(1);
};
lives_ok {
$ctx->hide;
};
lives_ok {
$ctx->unhide;
};
if(@contexts) {
$run->();
} else {
$cond->send;
( run in 0.856 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )