| 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 |
|
|
BEGIN { plan tests => 8 }; |
| 11 |
|
|
|
| 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 |
|
|
my $ret = $tdb->store(foo => 'bar', MODIFY); |
| 22 |
|
|
ok(!$ret); |
| 23 |
|
|
ok($tdb->error, ERR_NOEXIST); |
| 24 |
|
|
ok($tdb->errorstr, 'Record does not exist'); |
| 25 |
|
|
|
| 26 |
|
|
$ret = $tdb->store(foo => 'bar', INSERT); |
| 27 |
|
|
ok($ret); |
| 28 |
|
|
|
| 29 |
|
|
undef $tdb; |
| 30 |
|
|
|
| 31 |
|
|
ok($tdb = TDB_FileX->open("test.tdb")); |
| 32 |
|
|
|
| 33 |
|
|
ok($tdb->fetch('foo'), 'bar'); |