Fixed case where no uuid module found so that it dies with error, not with method...
[dbsrgits/DBIx-Class-UUIDColumns.git] / t / lib / UUIDTest.pm
1 package # hide from PAUSE 
2     UUIDTest;
3
4 use strict;
5 use warnings;
6 use UUIDTest::Schema;
7
8 sub initialise {
9
10   my $db_file = "t/var/UUIDTest.db";
11   
12   unlink($db_file) if -e $db_file;
13   unlink($db_file . "-journal") if -e $db_file . "-journal";
14   mkdir("t/var") unless -d "t/var";
15   
16   my $dsn = "dbi:SQLite:${db_file}";
17   
18   return UUIDTest::Schema->compose_connection('UUIDTest' => $dsn);
19 }
20   
21 sub is_uuid {
22     my $value = defined $_[0] ? shift : '';
23
24     return ($value =~ m/  ^[0-9a-f]{8}-
25                            [0-9a-f]{4}-
26                            [0-9a-f]{4}-
27                            [0-9a-f]{4}-
28                            [0-9a-f]{12}$
29                       /ix);
30 };
31
32 1;