/[wait]/trunk/t/insert.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/t/insert.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (show annotations)
Wed Jul 14 07:35:56 2004 UTC (19 years, 10 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1181 byte(s)
fix more tests and code

1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Test::More;
6 use blib;
7
8 BEGIN { use_ok('WAIT::Database'); }
9 END { system 'rm -rf test' if -d 'test'; }
10
11 plan tests => 21;
12
13 ok(my $db = WAIT::Database->create(name => 'test'), "create");
14
15 ok(my $tb = $db->create_table(name => 'sample', attr => ['docid', 'term']), "create_table");
16
17 ok(my $tid = $tb->insert(docid => 1, term => 'IR'), "insert IR");
18
19 $tb->sync;
20
21 ok(my %tp = $tb->fetch($tid), "fetch");
22 ok(($tp{docid} == 1 and $tp{term} eq 'IR'), "fetch == IR");
23
24 ok($tb->close, "tb->close");
25
26 ok($db->close, "db->close");
27
28 ok($db = WAIT::Database->open(name => 'test'), "open");
29
30 ok($tb = $db->table(name => 'sample'), "table");
31
32 ok($tb->open, "open");
33
34 ok(%tp = $tb->fetch($tid), "fetch");
35 ok(($tp{docid} == 1 and $tp{term} eq 'IR'), "fetch == IR");
36
37 ok($tb->delete(%tp), "delete");
38
39 ok($tb->delete_by_key($tid), "delete_by_key");
40
41 # can we reuse tid?
42 ok(my $ntid = $tb->insert(docid => 1, term => 'IR'), "tid reuse");
43
44 ok(%tp = $tb->fetch($ntid), "fetch");
45 ok(($tp{docid} == 1 and $tp{term} eq 'IR'), "fetch == IR");
46
47 ok($tb->close, "close");
48
49 # clean up
50 ok($db->dispose, "dispose");
51 ok(!defined $db, "undef db");
52 ok(defined $tb,"defined tb");
53

Properties

Name Value
cvs2svn:cvs-rev 1.1

  ViewVC Help
Powered by ViewVC 1.1.26