| 1 |
root |
1.1 |
#! /usr/bin/perl -w |
| 2 |
|
|
|
| 3 |
|
|
# |
| 4 |
|
|
# test persistant storage and error returns |
| 5 |
|
|
# |
| 6 |
|
|
|
| 7 |
|
|
use Test; |
| 8 |
|
|
use Fcntl; |
| 9 |
|
|
|
| 10 |
root |
1.2 |
BEGIN { plan tests => 9 }; |
| 11 |
root |
1.1 |
|
| 12 |
|
|
use TDB_FileX ":all"; |
| 13 |
|
|
|
| 14 |
|
|
unlink("test.tdb"); |
| 15 |
|
|
my $tdb = TDB_FileX->open("test.tdb", tdb_flags => DEFAULT, open_flags => O_RDWR, mode => 0664); |
| 16 |
|
|
ok(!$tdb); |
| 17 |
|
|
|
| 18 |
|
|
$tdb = TDB_FileX->open("test.tdb", tdb_flags => CLEAR_IF_FIRST); |
| 19 |
|
|
ok($tdb); |
| 20 |
|
|
|
| 21 |
root |
1.2 |
ok (!eval { $tdb->store (foo => 'bar', MODIFY), 1 }); |
| 22 |
|
|
ok($! == TDB_FileX::ERR_NOEXIST); |
| 23 |
root |
1.1 |
ok($tdb->error, ERR_NOEXIST); |
| 24 |
|
|
ok($tdb->errorstr, 'Record does not exist'); |
| 25 |
|
|
|
| 26 |
root |
1.2 |
ok (eval { $tdb->store (foo => 'bar', INSERT); 1 }); |
| 27 |
root |
1.1 |
|
| 28 |
|
|
undef $tdb; |
| 29 |
|
|
|
| 30 |
|
|
ok($tdb = TDB_FileX->open("test.tdb")); |
| 31 |
|
|
|
| 32 |
|
|
ok($tdb->fetch('foo'), 'bar'); |