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

Last change on this file was 19, checked in by peter, 19 years ago
  • added "status_callback" option to the constructor for MP3::Find::DB
  • default status callback just prints the status code and the file name to STDERR as before
  • using an empty status_callback in t/03-db.t (status_callback => sub {}) to keep the test output more legible
  • updated docs in Find.pm
  • mkreadme now prints a blank line between the file header and the DESCRIPION section
  • generated new README file
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(
26    status_callback => sub {},  # be quiet about updates
27);
28isa_ok($finder, 'MP3::Find::DB');
29
30eval { $finder->create_db()  };
31ok($@, 'create_db dies when not given a database name');
32eval { $finder->update_db()  };
33ok($@, 'update_db dies when not given a database name');
34eval { $finder->destroy_db() };
35ok($@, 'destroy_db dies when not given a database name');
36
37
38# create a test db
39unlink $DB_FILE;
40$finder->create_db($DB_FILE);
41ok(-e $DB_FILE, 'db file is there');
42
43my $count = $finder->update_db($DB_FILE, $SEARCH_DIR);
44is($count, $MP3_COUNT, 'added all the mp3s to the db');
45
46# remove the db
47$finder->destroy_db($DB_FILE);
48ok(!-e $DB_FILE, 'db file is gone');
49
50#TODO: get some test mp3s
51#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.