File: 22-general.t

package info (click to toggle)
libaudio-mpd-perl 2.004-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 356 kB
  • sloc: perl: 1,444; makefile: 6
file content (65 lines) | stat: -rw-r--r-- 1,572 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!perl
#
# This file is part of Audio-MPD
#
# This software is copyright (c) 2007 by Jerome Quelin.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#

use strict;
use warnings;

use Audio::MPD;
use Test::More;

# are we able to test module?
eval 'use Test::Corpus::Audio::MPD';
plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s;

plan tests => 7;
my $mpd = Audio::MPD->new;


#
# testing mpd version.
SKIP: {
    my $output = qx{echo | nc -w1 localhost 6600 2>/dev/null};
    skip 'need netcat installed', 1 unless $output =~ /^OK .* ([\d.]+)\n/;
    is( $mpd->version, $1, 'mpd version grabbed during connection' );
}


#
# testing kill.
$mpd->ping;
$mpd->kill;
sleep 1; # let mpd shut down the socket cleanly
eval { $mpd->ping };
like( $@, qr/^Could not create socket:/, 'kill shuts mpd down' );
start_test_mpd();


#
# testing password changing.
eval { $mpd->set_password('b0rken') };
like( $@, qr/\{password\} incorrect password/, 'changing password' );
eval { $mpd->set_password() }; # default to empty string.
is( $@, '', 'no password = empty password' );


#
# testing database updating.
# uh - what are we supposed to test? that there was no error?
eval { $mpd->updatedb };
is( $@, '', 'updating whole collection' );
sleep 1; # let the first update finish.
eval { $mpd->updatedb('dir1') };
is( $@, '', 'updating part of collection' );


#
# testing urlhandlers.
my @handlers = $mpd->urlhandlers;
ok( scalar @handlers >= 1, 'at least one url handler supported' );