Annotation of HOPE/Net-OpenAMD/t/network_tests.t, Revision 1.5
1.1 andrew 1: #!perl
2: package NetworkTests;
1.2 andrew 3:
1.5 ! andrew 4: # $AFresh1: network_tests.t,v 1.4 2010/06/27 00:52:33 andrew Exp $
1.1 andrew 5:
6: use strict;
7: use warnings;
8:
9: use Test::More;
10: use Net::OpenAMD;
11:
1.2 andrew 12: if ( !caller() ) {
13: if ( $ENV{'NETWORK_TESTS'} ) {
14:
15: # plan tests => ??;
1.1 andrew 16: }
17: else {
1.5 ! andrew 18: plan skip_all => 'Network test. Set $ENV{NETWORK_TESTS} to a true value to run.';
1.1 andrew 19: }
20:
21: my $amd = Net::OpenAMD->new();
22: run_tests($amd);
23:
24: done_testing();
25: }
26:
27: 1;
28:
29: sub run_tests {
30: my ($amd) = @_;
31:
1.2 andrew 32: my %tests = (
33: location => [
34: { args => undef,
1.4 andrew 35: expect => [
36: { 'y' => '83.1452331542969',
37: 'area' => 'Engressia',
38: 'time' => 2387,
39: 'user' => 12983,
40: 'x' => '46.7369918823242',
41: 'button' => 'False'
42: }
43: ],
1.2 andrew 44: },
45: ],
46: speakers => [
47: { args => undef,
1.4 andrew 48: expect => [
49: { 'name' => 'Johnny',
50: 'bio' => 'Johnny\'s bio'
51: },
52: ],
1.2 andrew 53: },
54: ],
55: talks => [
56: { args => undef,
1.4 andrew 57: expect => [
58: { 'speakers' => [ 'Judas', 'JohnnyX' ],
59: 'interests' => [ 'media', 'crypto' ],
60: 'time' => '2008/7/18 13:00:00',
61: 'track' => 'Hooper',
62: 'title' => 'Ancient Egyptian Music and DRM',
63: 'abstract' =>
64: '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.'
65: }
66: ],
1.2 andrew 67: },
68: ],
69: interests => [
70: { args => undef,
1.4 andrew 71: expect => [
72: 'new tech', 'activism',
73: 'radio', 'lockpicking',
74: 'crypto', 'privacy',
75: 'ethics', 'telephones',
76: 'social engineering', 'hacker spaces',
77: 'hardware hacking', 'nostalgia',
78: 'communities', 'science',
79: 'government', 'network security',
80: 'malicious software', 'pen testing',
81: 'web', 'niche hacks',
82: 'media',
83: ],
1.2 andrew 84: },
85: ],
86: users => [
87: { args => undef,
1.4 andrew 88: expect => [
89: { 'name' => 'JohnnyX',
90: 'x' => '32.54091324',
91: 'y' => '54.10958384',
92: 'interests' => [
93: 'new tech', 'radio',
94: 'lockpicking', 'crypto',
95: 'telephones', 'social engineering',
96: 'hacker spaces', 'hardware hacking',
97: 'nostalgia', 'communities',
98: 'science', 'network security',
99: 'malicious software', 'pen testing'
100: ],
101: }
102: ]
1.2 andrew 103: },
104: ],
105: stats => [
106: { args => undef,
1.4 andrew 107: expect => qr/^Unused \s feature/xms,
1.2 andrew 108: },
109: ],
110: );
111:
112: foreach my $method ( keys %tests ) {
113: foreach my $test ( @{ $tests{$method} } ) {
114: no warnings 'uninitialized';
115: my $result;
116: eval { $result = $amd->$method( $test->{args} ) };
1.4 andrew 117: if ( ref $test->{expect} eq 'Regexp' ) {
118: like( $@, $test->{expect}, "AMD->$method($test->{args})" );
119: }
120: elsif ( ref $test->{expect} ) {
121: is( $@, '', "AMD->$method($test->{args})" );
122: is_deeply( $result, $test->{expect}, 'got expected result' );
123: }
124: else {
125: is( $@, $test->{expect}, "AMD->$method($test->{args})" );
126: }
1.2 andrew 127: }
128: }
1.1 andrew 129: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>