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

Last change on this file since 41 was 41, checked in by peter, 11 years ago

Fixed failing tests by correcting test plan numbers and moving the plan above the first use_ok call.

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    plan tests => 8;
15    use_ok('MP3::Find::DB')
16};
17
18my $SEARCH_DIR = 't/mp3s';
19my $DB_FILE = 't/mp3.db';
20my $MP3_COUNT = 1;
21
22# exercise the object
23
24my $finder = MP3::Find::DB->new(
25    status_callback => sub {},  # be quiet about updates
26);
27isa_ok($finder, 'MP3::Find::DB');
28
29eval { $finder->create_db()  };
30ok($@, 'create_db dies when not given a database name');
31eval { $finder->update_db()  };
32ok($@, 'update_db dies when not given a database name');
33eval { $finder->destroy_db() };
34ok($@, 'destroy_db dies when not given a database name');
35
36
37# create a test db
38unlink $DB_FILE;
39$finder->create_db($DB_FILE);
40ok(-e $DB_FILE, 'db file is there');
41
42my $count = $finder->update_db($DB_FILE, $SEARCH_DIR);
43is($count, $MP3_COUNT, 'added all the mp3s to the db');
44
45# remove the db
46$finder->destroy_db($DB_FILE);
47ok(!-e $DB_FILE, 'db file is gone');
48
49#TODO: get some test mp3s
50#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.