File: 09_badfile.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 (36 lines) | stat: -rw-r--r-- 625 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
#!/usr/bin/perl

# Test ORLite's behaviour when the SQLite file is broken

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

use Test::More tests => 2;
use Test::Script;
use File::Remove;
use t::lib::Test;

# Where the test file will be
my $file = test_db();
ok( ! -f $file, 'File does not exist' );

# Corrupt the database file
open( FILE, '>', $file ) or die("open: $!");
print FILE "broken" or die("print: $!");
close FILE          or die("close: $!");

# Try to load the database
eval <<'END_PERL';
package Foo;

use ORLite {
	file  => $file,
	prune => 1,
};

1;
END_PERL
ok( $@, 'Loading a bad database throws an exception' );