source: mp3-find/tags/0.03/t/03-db.t

Last change on this file was 12, checked in by peter, 19 years ago
  • added "exclude_path" option to Filesystem backend
  • added an excluded directory to the test suite ("t/dont_look_here")
  • fixed dying DB test (still a workaround for a DBD::SQLite problem)
File size: 1.3 KB
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use Test::More;
5
6BEGIN {
7    eval { require DBI };
8    plan skip_all => 'DBI required to use MP3::Find::DB backend' if $@;
9    eval { require DBD::SQLite };
10    plan skip_all => 'DBD::SQLite required to use MP3::Find::DB backend' if $@;
11    eval { require SQL::Abstract };
12    plan skip_all => 'SQL::Abstract required to use MP3::Find::DB backend' if $@;
13   
14    use_ok('MP3::Find::DB')
15};
16
17plan tests => 7;
18
19my $SEARCH_DIR = 't/mp3s';
20my $DB_FILE = 't/mp3.db';
21my $MP3_COUNT = 1;
22
23# exercise the object
24
25my $finder = MP3::Find::DB->new;
26isa_ok($finder, 'MP3::Find::DB');
27
28eval { $finder->create_db()  };
29ok($@, 'create_db dies when not given a database name');
30eval { $finder->update_db()  };
31ok($@, 'update_db dies when not given a database name');
32eval { $finder->destroy_db() };
33ok($@, 'destroy_db dies when not given a database name');
34
35
36# create a test db
37unlink $DB_FILE;
38$finder->create_db($DB_FILE);
39ok(-e $DB_FILE, 'db file is there');
40
41my $count = $finder->update_db($DB_FILE, $SEARCH_DIR);
42is($count, $MP3_COUNT, 'added all the mp3s to the db');
43
44# remove the db
45$finder->destroy_db($DB_FILE);
46ok(!-e $DB_FILE, 'db file is gone');
47
48#TODO: get some test mp3s
49#TODO: write a set of common set of test querys and counts for all the backends
Note: See TracBrowser for help on using the repository browser.