[project @ 6332]
[audio-mpd-common.git] / t / 40-cmds-general.t
blob4c4ab3d6f569de5cdb266fb3947255944c678795
1 #!perl
3 # This file is part of POE::Component::Client::MPD.
4 # Copyright (c) 2007 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 POE qw[ Component::Client::MPD::Message ];
15 use Readonly;
16 use Test::More;
18 our $nbtests = 5;
19 our @tests   = (
20     # [ 'event', [ $arg1, $arg2, ... ], $answer_back, \&check_results ]
22     # updatedb
23     [ 'updatedb',    [],       $SLEEP1,  undef               ],
24     [ 'stats',       [],       $SEND,    \&check_update      ],
25     [ 'updatedb',    ['dir1'], $DISCARD, undef               ],
26     [ 'stats',       [],       $SEND,    \&check_update      ],
28     # version
29     # needs to be *after* updatedb, so version messages can be treated.
30     [ 'version',     [],       $SEND,    \&check_version     ],
32     # urlhandlers
33     [ 'urlhandlers', [],       $SEND,    \&check_urlhandlers ],
37 # are we able to test module?
38 eval 'use POE::Component::Client::MPD::Test';
39 plan skip_all => $@ if $@ =~ s/\n+BEGIN failed--compilation aborted.*//s;
40 exit;
42 sub check_version {
43     SKIP: {
44         my $output = qx[mpd --version 2>/dev/null];
45         skip 'need mpd installed', 1 unless $output =~ /^mpd .* ([\d.]+)\n/;
46         is( $_[0]->data, $1, 'mpd version grabbed during connection' );
47     }
49 sub check_update  {
50     my $stats = $_[0]->data;
51     isnt( $stats->db_update,  0, 'database has been updated' );
54 sub check_urlhandlers {
55     my @handlers = @{ $_[0]->data };
56     is( scalar @handlers,     1, 'only one url handler supported' );
57     is( $handlers[0], 'http://', 'only http is supported by now' );