* convert over to Module::Build
[bioperl-db.git] / t / 06comment.t
bloba10343d4d13c6890dceffea1676b15d3d8cf8e27
1 # -*-Perl-*-
2 # $Id$
4 BEGIN {
5     use lib 't';
6     use Bio::Root::Test;
7     test_begin(-tests => 14);
9         use_ok('DBTestHarness');
10         use_ok('Bio::SeqIO');
11         use_ok('Bio::Annotation::Comment');
14 $biosql = DBTestHarness->new("biosql");
15 $db = $biosql->get_DBAdaptor();
16 ok $db;
18 my $seqio = Bio::SeqIO->new('-format' => 'genbank',
19                             '-file' => test_input_file('parkin.gb'));
20 my $seq = $seqio->next_seq();
21 ok $seq;
22 my $pseq = $db->create_persistent($seq);
23 $pseq->namespace("mytestnamespace");
24 # store seq
25 $pseq->create();
26 ok $pseq->primary_key();
28 $adp = $db->get_object_adaptor("Bio::Annotation::Comment");
29 ok $adp;
31 # start try/finally
32 eval {
33     my $comment = Bio::Annotation::Comment->new();
34     $comment->text("Some text");
35     
36     my $pcomment = $adp->create_persistent($comment);
37     $pcomment->rank(10);
38     $pcomment->create(-fkobjs => [$pseq]);
39     ok $pcomment->primary_key();
41     my $dbcomment = $adp->find_by_primary_key($pcomment->primary_key());
42     
43     ok $dbcomment;
44     
45     is ($dbcomment->text, $comment->text);
48 print STDERR $@ if $@;
50 # delete seq
51 is ($pseq->remove(), 1);
52 my $ns = Bio::DB::Persistent::BioNamespace->new(-identifiable => $pseq);
53 ok $ns = $db->get_object_adaptor($ns)->find_by_unique_key($ns);
54 ok $ns->primary_key();
55 is ($ns->remove(), 1);