File: 22_overlay.t

package info (click to toggle)
liborlite-perl 2.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 2,471; sql: 97; makefile: 2
file content (75 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl

# Tests that overlay modules are automatically loaded

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

use Test::More tests => 7;
use File::Spec::Functions ':ALL';
use lib 't/lib';
use LocalTest;





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

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

# Create the test package
eval <<"END_PERL"; die $@ if $@;
package MyDB;

use strict;
use ORLite {
	file => '$file',
};

1;
END_PERL





#####################################################################
# Tests for the base package update methods

isa_ok(
	MyDB::TableOne->create(
		col1 => 1,
		col2 => 'foo',
	),
	'MyDB::TableOne',
);

isa_ok(
	MyDB::TableOne->create(
		col1 => 2,
		col2 => 'bar',
	),
	'MyDB::TableOne',
);
is( MyDB::TableOne->count, 2, 'Found 2 rows' );

is(
	MyDB::TableOne->count,
	2,
	'Count found 2 rows',
);

SCOPE: {
	my $object = MyDB::TableOne->load(1);
	isa_ok( $object, 'MyDB::TableOne' );
	is( $object->dummy, 2, '->dummy ok (overlay was loaded)' );
}