3 # This file is part of Audio::MPD.
4 # Copyright (c) 2007 Jerome Quelin <jquelin@cpan.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or (at
9 # your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 # are we able to test module?
29 eval 'use Audio::MPD::Test';
30 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
34 my $mpd = Audio::MPD->new;
35 isa_ok($mpd, 'Audio::MPD');
39 # testing error during socket creation.
41 eval { $mpd->_send_command( "ping\n" ) };
42 like($@, qr/^Could not create socket/, 'error during socket creation');
46 # testing connection to a non-mpd server - here, we'll try to connect
47 # to a sendmail server.
48 my $sendmail_running = grep { /:25\s.*LISTEN/ } qx[ netstat -an ];
50 skip 'need some sendmail server running', 1 unless $sendmail_running;
53 like($@, qr/^Not a mpd server - welcome string was:/, 'wrong server');
59 # testing password sending.
60 $mpd->_password( 'wrong-password' );
62 like($@, qr/\{password\} incorrect password/, 'wrong password');
64 $mpd->_password('fulladmin');
66 is($@, '', 'correct password sent');
72 eval { $mpd->_send_command( "bad command\n" ); };
73 like($@, qr/unknown command "bad"/, 'unknown command');
75 my @output = $mpd->_send_command( "status\n" );
76 isnt(scalar @output, 0, 'commands return stuff');