#!perl
package NetworkTests;
# $AFresh1: network_tests.t,v 1.3 2010/06/26 16:50:40 andrew Exp $
use strict;
use warnings;
use Test::More;
use Net::OpenAMD;
if ( !caller() ) {
if ( $ENV{'NETWORK_TESTS'} ) {
# plan tests => ??;
}
else {
plan skip_all => "Set env NETWORK_TESTS to test";
}
my $amd = Net::OpenAMD->new();
run_tests($amd);
done_testing();
}
1;
sub run_tests {
my ($amd) = @_;
my %tests = (
location => [
{ args => undef,
expect => {},
},
],
speakers => [
{ args => undef,
expect => {},
},
],
talks => [
{ args => undef,
expect => {},
},
],
interests => [
{ args => undef,
expect => {},
},
],
users => [
{ args => undef,
expect => {},
},
],
stats => [
{ args => undef,
expect => {},
},
],
);
foreach my $method ( keys %tests ) {
foreach my $test ( @{ $tests{$method} } ) {
no warnings 'uninitialized';
my $result;
eval { $result = $amd->$method( $test->{args} ) };
is( $@, undef, "AMD->$method($test->{args})" );
is( $result, $test->{expect}, 'got expected result' );
}
}
}