AnyEvent-Twitter-Stream
view release on metacpan or search on metacpan
t/streaming.t view on Meta::CPAN
use strict;
use warnings;
use AnyEvent;
use AnyEvent::Twitter::Stream;
use AnyEvent::Util qw(guard);
use Data::Dumper;
use JSON;
use Test::More;
use Test::TCP;
use Test::Requires qw(Plack::Builder Plack::Handler::Twiggy Try::Tiny);
use Test::Requires { 'Plack::Request' => '0.99' };
my @pattern = (
{
method => 'sample',
mount => 'stream',
path => '/1.1/statuses/sample.json',
option => {},
},
{
method => 'firehose',
mount => 'stream',
path => '/1.1/statuses/firehose.json',
option => {},
},
{
method => 'filter',
mount => 'stream',
path => '/1.1/statuses/filter.json',
option => {track => 'hogehoge'},
},
{
method => 'filter',
path => '/1.1/statuses/filter.json',
option => {follow => '123123'},
},
{
method => 'userstream',
path => '/1.1/user.json',
option => {},
},
);
foreach my $enable_chunked (0, 1) {
test_tcp(
client => sub {
my $port = shift;
local $AnyEvent::Twitter::Stream::STREAMING_SERVER = "127.0.0.1:$port";
local $AnyEvent::Twitter::Stream::USERSTREAM_SERVER = "127.0.0.1:$port";
local $AnyEvent::Twitter::Stream::US_PROTOCOL = "http";
local $AnyEvent::Twitter::Stream::PROTOCOL = 'http'; # real world API uses https
foreach my $item (@pattern) {
my $destroyed;
my $received = 0;
my $count_max = 5;
my ($deleted, $event) = (0, 0);
note("try $item->{method}");
{
my $done = AE::cv;
my $streamer = AnyEvent::Twitter::Stream->new(
username => 'test',
password => 's3cr3t',
( run in 3.021 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )