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;
33 my $mpd = Audio::MPD->new;
37 # testing mpd version.
39 my $output = qx[mpd --version 2>/dev/null];
40 skip 'need mpd installed', 1 unless $output =~ /^mpd .* ([\d.]+)\n/;
41 is( $mpd->version, $1, 'mpd version grabbed during connection' );
50 like( $@, qr/^Could not create socket:/, 'kill shuts mpd down' );
55 # testing password changing.
56 eval { $mpd->password('b0rken') };
57 like( $@, qr/\{password\} incorrect password/, 'changing password' );
58 eval { $mpd->password() }; # default to empty string.
59 is( $@, '', 'no password = empty password' );
63 # testing database updating.
64 # uh - what are we supposed to test? that there was no error?
65 eval { $mpd->updatedb };
66 is( $@, '', 'updating whole collection' );
67 sleep 1; # let the first update finish.
68 eval { $mpd->updatedb('dir1') };
69 is( $@, '', 'updating part of collection' );
73 # testing urlhandlers.
74 my @handlers = $mpd->urlhandlers;
75 is( scalar @handlers, 1, 'only one url handler supported' );
76 is( $handlers[0], 'http://', 'only http is supported by now' );