X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2Fstemmatology.git;a=blobdiff_plain;f=t%2Ftext_tradition_directory.t;h=8950148cb14e6eeb175c7a4f187ddf08ca7874e3;hp=e4de126abfab534a132f3e81aa79315dc614c833;hb=62a39b8f5d0ae86b26350664828069a2a44f5645;hpb=9ba651b9a7717e06b04d524277307df39bcfd8e8 diff --git a/t/text_tradition_directory.t b/t/text_tradition_directory.t index e4de126..8950148 100644 --- a/t/text_tradition_directory.t +++ b/t/text_tradition_directory.t @@ -36,7 +36,7 @@ my $t = Text::Tradition->new( my $s = $t->add_stemma( dotfile => 't/data/simple.dot' ); ok( $d->save( $t ), "Updated tradition with stemma" ); is( $d->tradition( $uuid ), $t, "Correct tradition returned for id" ); - is( $d->tradition( $uuid )->stemma, $s, "...and it has the correct stemma" ); + is( $d->tradition( $uuid )->stemma(0), $s, "...and it has the correct stemma" ); try { $d->save( $s ); } catch( Text::Tradition::Error $e ) { @@ -55,13 +55,16 @@ is( ref( $nt ), 'Text::Tradition', "Made new tradition" ); { my $f = Text::Tradition::Directory->new( 'dsn' => $dsn ); my $scope = $f->new_scope; - is( scalar $f->tradition_ids, 1, "Directory index has our tradition" ); + is( scalar $f->traditionlist, 1, "Directory index has our tradition" ); my $nuuid = $f->save( $nt ); ok( $nuuid, "Stored second tradition" ); - is( scalar $f->tradition_ids, 2, "Directory index has both traditions" ); + my @tlist = $f->traditionlist; + is( scalar @tlist, 2, "Directory index has both traditions" ); my $tf = $f->tradition( $uuid ); + my( $tlobj ) = grep { $_->{'id'} eq $uuid } @tlist; + is( $tlobj->{'name'}, $tf->name, "Directory index has correct tradition name" ); is( $tf->name, $t->name, "Retrieved the tradition from a new directory" ); - my $sid = $f->object_to_id( $tf->stemma ); + my $sid = $f->object_to_id( $tf->stemma(0) ); try { $f->tradition( $sid ); } catch( Text::Tradition::Error $e ) { @@ -75,17 +78,21 @@ is( ref( $nt ), 'Text::Tradition', "Made new tradition" ); like( $e->message, qr/Cannot directly delete non-Tradition object/, "Exception has correct message" ); } + $f->delete( $uuid ); ok( !$f->exists( $uuid ), "Object is deleted from DB" ); ok( !$f->exists( $sid ), "Object stemma also deleted from DB" ); - is( scalar $f->tradition_ids, 1, "Object is deleted from index" ); + is( scalar $f->traditionlist, 1, "Object is deleted from index" ); } -SKIP: { - skip 'Have yet to figure out garbage collection', 1; +{ my $g = Text::Tradition::Directory->new( 'dsn' => $dsn ); my $scope = $g->new_scope; - is( scalar $g->tradition_ids, 1, "Now one object in new directory index" ); + is( scalar $g->traditionlist, 1, "Now one object in new directory index" ); + my $ntobj = $g->tradition( 'CX' ); + my @w1 = sort { $a->sigil cmp $b->sigil } $ntobj->witnesses; + my @w2 = sort{ $a->sigil cmp $b->sigil } $nt->witnesses; + is_deeply( \@w1, \@w2, "Looked up remaining tradition by name" ); } }