File: [local] / HOPE / Net-OpenAMD / t / network_tests.t (download)
Revision 1.2, Sat Jun 26 16:47:01 2010 UTC (14 years ago) by andrew
Branch: MAIN
Changes since 1.1: +49 -6 lines
an initial testing framework for what I want to pass.
|
#!perl
package NetworkTests;
# $AFresh1: network_tests.t,v 1.2 2010/06/26 16:47:01 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, "$method($test->{args})" );
is( $result, $test->{expect}, 'got expected result' );
}
}
}