AnyEvent-WebService-Tracks
view release on metacpan or search on metacpan
t/02-context.t view on Meta::CPAN
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->();
};
run_tests_in_loop {
my ( $cond ) = @_;
$tracks->create_context('One', sub {
my ( $ctx, $error ) = @_;
ok(! $ctx);
ok($error);
$cond->send;
});
};
run_tests_in_loop {
my ( $cond ) = @_;
$tracks->contexts(sub {
my ( $contexts ) = @_;
my ( $one ) = @$contexts;
$one->name('Not one');
$one->position(4);
$one->unhide;
my $updated_at = $one->updated_at;
my $timer;
$timer = AnyEvent->timer(
after => 2,
cb => sub {
undef $timer;
$one->update(sub {
my ( $ctx ) = @_;
ok($ctx);
is($ctx->name, 'Not one');
is($ctx->position, 4);
ok(! $ctx->is_hidden);
ok($ctx->updated_at > $updated_at);
$cond->send;
});
},
);
});
};
run_tests_in_loop {
my ( $cond ) = @_;
$tracks->contexts(sub {
my ( $contexts ) = @_;
my ( $one, $two ) = @$contexts;
$one->name($two->name);
$one->update(sub {
my ( $ctx, $error ) = @_;
ok(! $ctx);
ok($error);
$cond->send;
});
});
};
run_tests_in_loop {
my ( $cond ) = @_;
$tracks->contexts(sub {
my ( $contexts ) = @_;
my ( $one ) = @$contexts;
my $copy = dclone($one);
$one->update(sub {
my ( $c ) = @_;
is_deeply($c, $copy);
$cond->send;
});
});
};
run_tests_in_loop {
my ( $cond ) = @_;
$tracks->contexts(sub {
my ( $contexts ) = @_;
( run in 0.782 second using v1.01-cache-2.11-cpan-85f18b9d64f )