use strict;
use Test::More tests => 16;
use WWW::Tube8;

eval {
    my $t8 = WWW::Tube8->new;
};
like $@, qr/opt needs hash ref/, 'new : not hash';

eval {
    my $t8 = WWW::Tube8->new({});
};
like $@, qr/url is required/, 'new : no url';

eval {
    my $t8 = WWW::Tube8->new({ url => 'http://www.example.com/' });
};
like $@, qr/url is wrong/, 'new : not tube8 url';

my $ua = LWP::UserAgent->new(agent => 'WWW::Tube8.test');
my $t8 = WWW::Tube8->new({
    url => 'http://www.tube8.com/asian/japanese-av-haruka-sanada/71930/',
    ua  => $ua,
});
isa_ok $t8, 'WWW::Tube8', 'new : WWW::Tube8';
is $t8->{ua}->agent, 'WWW::Tube8.test', 'new : agent';

like $t8->flv,
     qr/http:\/\/media\d+\.tube8\.com\/flv\/.+\.flv/,
     'flv : get url of flv file';

is $t8->thumb, 'http://www.tube8.com/v/640x480/71930.jpg', 'thumb : get url of thumbnail file';

like $t8->get_3gp,
     qr/http:\/\/mobile\d+\.tube8\.com\/flv\/.+\.3gp/,
     'get_3gp : get url of 3gp file';

is $t8->url, 'http://www.tube8.com/asian/japanese-av-haruka-sanada/71930/', 'url : get url of video';

is $t8->id, '71930', 'id : get id of video';

is $t8->title, 'Japanese AV Haruka Sanada', 'title : get title of video';

is $t8->title_inurl, 'japanese-av-haruka-sanada', 'title_inurl : get title of video for url';

is $t8->category, 'Asian', 'category : get category of video';

is $t8->category_url, 'http://www.tube8.com/cat/asian/12/', 'category_url : get category link of video';

is $t8->duration, '23:00', 'duration : get duration of video';

# rewrite url for test (can not download url)
$t8->url('http://www.example.com/test/hoge-hage-foo-bar/77777/');
eval { $t8->_get_info; }; # it is no good to do like that. for test only.
like $@, qr/can't get tube8 page/, '_get_info : wrong url';


