File: 3ext.t

package info (click to toggle)
libdbix-sequence-perl 1.5-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 294; makefile: 2
file content (74 lines) | stat: -rwxr-xr-x 1,655 bytes parent folder | download | duplicates (4)
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
do { print "1..0\n"; exit; } if (not -e 't/config.pl');

print "1..1\n";

print STDERR "\n\nTesting ID release...\n";
use DBIx::Sequence;

my $config;
open(CONF, "t/config.pl") || &creve("Could not open t/config.pl");
while(<CONF>) { $config .= $_; }
close CONF;
$config = eval $config;
if($@)
{
        &creve($@);
}

$ENV{'ORACLE_HOME'} = $config->{oracle_home} if(!$ENV{'ORACLE_HOME'});

my $sequence = new DBIx::Sequence({
                                                db_dsn => $config->{dsn},
                                                db_user => $config->{user},
                                                db_pw => $config->{userpw},
																state_table => $config->{state_table},
                                                release_table => $config->{release_table},
                                                }) || &creve("Could now initiate a new DBIx::Sequence object.");
my $ids = {};
my $ids_second = {};

for(1..200)
{
	my $id = $sequence->Next('make_test');

	print STDERR "$id".("\b" x length($id));
	if( $ids->{$id} )
	{
		&creve("Sequence generated 2 identical id's.");
	}
	$ids->{$id} = $id;
}	
print STDERR "\n\n";

foreach my $id (keys %$ids)
{
	$sequence->Release('make_test',$id);
	#print STDERR ".";
}

print STDERR "Verifying releases...\n";
for(1..200)
{
	my $id = $sequence->Next('make_test');

	print STDERR "$id".("\b" x length($id));	
	if(!$ids->{$id})
	{
		&creve("Sequence did not relase ID $id");
	}
}
	
print "ok 1\n";


sub creve
{
	my $msg = shift;

	print STDERR "\n\n$msg\n";
	
	print STDERR "\nSomething is wrong.\n";
	print STDERR "Contact the author.\n";
	print "not ok 1\n";
	exit;
}