File: 07_pk.t

package info (click to toggle)
liborlite-perl 1.44-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 348 kB
  • ctags: 182
  • sloc: perl: 2,726; sql: 36; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl

# Tests relating to primary keys.

BEGIN {
	$|  = 1;
	$^W = 1;
}

use Test::More tests => 6;
use File::Spec::Functions ':ALL';
use t::lib::Test;


#####################################################################
# Set up for testing

# Connect
my $file = test_db();
my $dbh  = create_ok(
	file    => catfile(qw{ t 07_pk.sql }),
	connect => [ "dbi:SQLite:$file" ],
);

# Create the test package
eval <<"END_PERL"; die $@ if $@;
package Foo::Bar;

use strict;
use ORLite '$file';

1;
END_PERL


#####################################################################
# Run the tests

my @t1 = Foo::Bar::TableOne->select;
is( scalar(@t1), 9, 'Got 9 table_one objects' );
isa_ok( $t1[0], 'Foo::Bar::TableOne' );
is( $t1[2]->delete(), 1, 'One entry deleted');
@t1 = Foo::Bar::TableOne->select('where col1 = ?', 1);
is( scalar(@t1), 2, 'Got 2 table_one objects' );
@t1 = Foo::Bar::TableOne->select('where col1 = ? and col2 = ?', 1, 2);
is( $t1[0]->col3, 'b', 'Got line with col3 = b');