version 1.1, 2010/06/26 00:25:21 |
version 1.10, 2010/06/30 06:30:17 |
|
|
#!perl |
#!perl |
# $AFresh1$ |
# $AFresh1: local_server.t,v 1.9 2010/06/28 20:40:38 andrew Exp $ |
use Test::More;# tests => 75; |
use Test::More; |
|
|
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
#use File::Temp qw/ tempdir /; |
use Net::OpenAMD; |
#use File::Copy qw/ cp /; |
|
#use File::Spec; |
|
|
|
my $have_test_json = 1; |
|
|
|
BEGIN { |
BEGIN { |
|
use FindBin; |
|
use lib "$FindBin::Bin"; |
|
use lib "$FindBin::Bin/../../mojo/lib"; |
|
|
eval "use Test::Mojo::Server"; |
eval "use Test::Mojo::Server"; |
plan skip_all => "Test::Mojo::Server required for testing local server" if $@; |
if ($@) { |
|
plan skip_all => "Test::Mojo::Server required for testing local server"; |
|
} |
|
else { |
|
plan tests => 15; |
|
} |
|
require 'network_tests.t'; |
} |
} |
|
|
|
my %tests = ( |
|
location => [ |
|
{ args => undef, |
|
expect => [ |
|
{ 'y' => '83.1452331542969', |
|
'area' => 'Engressia', |
|
'time' => 2387, |
|
'user' => 12983, |
|
'x' => '46.7369918823242', |
|
'button' => 'False' |
|
} |
|
], |
|
}, |
|
], |
|
speakers => [ |
|
{ args => undef, |
|
expect => [ |
|
{ 'name' => 'Johnny', |
|
'bio' => 'Johnny\'s bio' |
|
}, |
|
], |
|
}, |
|
], |
|
talks => [ |
|
{ args => undef, |
|
expect => [ |
|
{ 'speakers' => [ 'Judas', 'JohnnyX' ], |
|
'interests' => [ 'media', 'crypto' ], |
|
'time' => '2008/7/18 13:00:00', |
|
'track' => 'Hooper', |
|
'title' => 'Ancient Egyptian Music and DRM', |
|
'abstract' => |
|
'A discussion of the development of musical notation, which was designed as a means of reproducing music while making it impossible for the general public to perform without permission.' |
|
} |
|
], |
|
}, |
|
], |
|
interests => [ |
|
{ args => undef, |
|
expect => [ |
|
'new tech', 'activism', |
|
'radio', 'lockpicking', |
|
'crypto', 'privacy', |
|
'ethics', 'telephones', |
|
'social engineering', 'hacker spaces', |
|
'hardware hacking', 'nostalgia', |
|
'communities', 'science', |
|
'government', 'network security', |
|
'malicious software', 'pen testing', |
|
'web', 'niche hacks', |
|
'media', |
|
], |
|
}, |
|
], |
|
users => [ |
|
{ args => undef, |
|
expect => [ |
|
{ 'name' => 'JohnnyX', |
|
'x' => '32.54091324', |
|
'y' => '54.10958384', |
|
'interests' => [ |
|
'new tech', 'radio', |
|
'lockpicking', 'crypto', |
|
'telephones', 'social engineering', |
|
'hacker spaces', 'hardware hacking', |
|
'nostalgia', 'communities', |
|
'science', 'network security', |
|
'malicious software', 'pen testing' |
|
], |
|
} |
|
] |
|
}, |
|
], |
|
stats => [ |
|
{ args => undef, |
|
expect => qr/^Unused \s feature/xms, |
|
}, |
|
], |
|
); |
|
|
my $server = Test::Mojo::Server->new(); |
my $server = Test::Mojo::Server->new(); |
$server->executable('test_server.pl'); |
$server->executable('test_server.pl'); |
#$server = $server->command('perl t/test_server.pl'); |
|
|
|
my $path = $server->find_executable_ok('executable found'); |
my $path = $server->find_executable_ok('executable found'); |
#print "PATH: $path\n"; |
|
#my $port = $server->generate_port_ok('port test'); |
|
|
|
my $port = $server->start_daemon_ok('daemon test'); |
my $port = $server->start_daemon_ok('daemon test'); |
print "Port: $port\n"; |
|
|
|
$server->server_ok('server running'); |
$server->server_ok('server running'); |
|
|
my $pid = $server->pid; |
my $amd = Net::OpenAMD->new( |
print "PID: $pid\n"; |
{ base_uri => 'http://127.0.0.1:' . $port . '/api/', } ); |
|
NetworkTests::run_tests( $amd, \%tests ); |
|
|
kill( 'TERM', $server->pid ); |
$server->stop_server_ok('server stopped'); |
$server->stop_server_ok('server stopped'); |
|
|
|
|
#done_testing(); |
|
|
done_testing(); |
|
exit; |
|