source: mp3-find/trunk/t/03-db.t @ 10

Last change on this file since 10 was 10, checked in by peter, 18 years ago
  • added test suite for the DB backend
  • doc corrections and updates to Find.pm and Base.pm
  • moved create and update database functions from mp3db to DB.pm
  • added "destroy_db" function to DB.pm
  • documented mp3db
  • set version to 0.02
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 = 0;
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.