mpd doesn't seem to provide an http urlhandler anymore
[audio-mpd.git] / t / 22-general.t
blob47337eff3b61efcc0b90b4685e8f15dde73efc96
1 #!perl
3 # This file is part of Audio::MPD
4 # Copyright (c) 2007-2008 Jerome Quelin, all rights reserved.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the same terms as Perl itself.
11 use strict;
12 use warnings;
14 use Audio::MPD;
15 use Test::More;
17 # are we able to test module?
18 eval 'use Audio::MPD::Test';
19 plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;
21 plan tests => 7;
22 my $mpd = Audio::MPD->new;
26 # testing mpd version.
27 SKIP: {
28     my $output = qx{echo | nc -w1 localhost 6600 2>/dev/null};
29     skip 'need netcat installed', 1 unless $output =~ /^OK .* ([\d.]+)\n/;
30     is( $mpd->version, $1, 'mpd version grabbed during connection' );
35 # testing kill.
36 $mpd->ping;
37 $mpd->kill;
38 eval { $mpd->ping };
39 like( $@, qr/^Could not create socket:/, 'kill shuts mpd down' );
40 start_test_mpd();
44 # testing password changing.
45 eval { $mpd->password('b0rken') };
46 like( $@, qr/\{password\} incorrect password/, 'changing password' );
47 eval { $mpd->password() }; # default to empty string.
48 is( $@, '', 'no password = empty password' );
52 # testing database updating.
53 # uh - what are we supposed to test? that there was no error?
54 eval { $mpd->updatedb };
55 is( $@, '', 'updating whole collection' );
56 sleep 1; # let the first update finish.
57 eval { $mpd->updatedb('dir1') };
58 is( $@, '', 'updating part of collection' );
62 # testing urlhandlers.
63 my @handlers = $mpd->urlhandlers;
64 is( scalar @handlers, 0, 'only one url handler supported' );
66 exit;